title: How to store selected value of unordered list or ordered list into variable?
body: <p>Let say I have an unordered list:</p>
  
  <pre><code>&lt;ul id="list"&gt;
  &lt;li&gt;Option1&lt;/li&gt;
  &lt;li&gt;Option2&lt;/li&gt;
  &lt;li&gt;Option3&lt;/li&gt;
  &lt;li&gt;Option4&lt;/li&gt;
  &lt;li&gt;Option5&lt;/li&gt;
  &lt;li&gt;Option6&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>So, whenever any of the list item selected or just gets clicked on by the user, it should store the selected value in x variable.</p>
  
  <p>Looking for answer with plain JavaScript.</p>
  
  <p>Thank you</p>