SHARE
TWEET

Untitled

a guest Jan 19th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <select id="filter" name="filter">
  2.     <option value="-1">Filter items</option>
  3.     <option value="sc">South Carolina</option>
  4.     <option value="nc">North Carolina</option>
  5. </select>
  6.  
  7.  
  8.  
  9. <div id="container">
  10.  
  11. <div class="box state-nc"></div>
  12. <div class="box state-sc"></div>
  13. <div class="box state-nc"></div>
  14. <div class="box state-sc"></div>
  15. <div class="box state-nc"></div>
  16. <div class="box state-sc"></div>
  17. <div class="box state-nc"></div>
  18. <div class="box state-sc"></div>    
  19. </div>
  20.    
  21. var $all_items = $('.item');
  22. var state = $dropdown.val();
  23. var $items = $('.item[class!="state-' + state + '"]');
  24. // or this:
  25. // var $items = $('.item[data-state!="' + state + '"]');
  26. if ($items.size() == $all_items) {
  27.   $all_items.fadeOut();
  28.   // show "no options found" instead
  29. } else {
  30.   $all_items.show();
  31.   $items.fadeOut();
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top