title: Javascript Help on Dropdown filter
body: <p>I was able to find a <a href="http://www.designchemical.com/lab/jquery/demo/jquery_demo_create_class_filter.htm" rel="nofollow noreferrer">solution</a> on Stackoverflow that display HTML "li" elements based on a filter (see attachement). Essentially based on css class'es defined in HTML elements, it populates the drop down list that you can select from.</p>
  
  <p>I would like to be modify javascript below so that when you navigate to one of the "li" elements pages (as seen here: <a href="https://jsfiddle.net/quwfmepL/2/" rel="nofollow noreferrer">https://jsfiddle.net/quwfmepL/2/</a> e.g. Note: Chose one Test1 element and it goes to the page1.html page) ..but when you hit the back button on the page1.html to page where filter resides, it doesn't remember last filter choice. As it does now, you are required to filter same choice again. I think what I need to do is look at the browser history, but not sure if there is an easier option. I was hoping it could be in the format of query string or like.</p>
  
  <pre><code>&lt;script type="text/JavaScript"&gt;
  $(document).ready(function() {
    var $tagList = $('#tag-list'),
        optionArr = [];
      $("#demo-list li a").each(function(index, item) {
      $.each($(this).attr('class').split(' '), function(i, option){
        if ($.inArray(option, optionArr) == -1) {
          $tagList.append('&lt;option value="'+option+'"&gt;'+option.replace('-', ' ').replace('_', ' ')+'&lt;/option&gt;');
          optionArr.push(option);
        }
      });
    });
    // Look at the URL for filter and modify here #
    $tagList.on('change', function() {
      var selection = $tagList.val();
      if (selection == "all") {
        $('#demo-list li a').show();
      } else {
        $('#demo-list li a').hide();
        $('#demo-list li a.'+selection).show();
      }
    });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Any suggestions or hints? Any help is appreciated.</p>
  
  <p><a href="https://i.stack.imgur.com/RhHj6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RhHj6.png" alt="enter image description here"></a></p>