javascript - Setting a variable using the value of multiple selects, each time any of the selects is changed -
i have list of items i'm trying "filter" set of 4 selects matching value of select options classes have applied list items. right now, have working each time choose new option of 4 selects, entire list reset, , items class matches value of option selected visible. have work each time new option selected of 4 selects, filter values of 4 selects, not 1 changed.
here's have right - appreciated!
$(".sort-options select").change(function() { var topics = $(this).val(); $(".list-schools li").hide().filter("." + topics).show(); });
$(".sort-options select").change(function() { var topics = ''; $(".sort-options select").each(function() { if ($(this).val()) { // create combined class .opt1.opt2.opt3 topics += "."+$(this).val(); } }); $(".list-schools li").each(function() { $(this).toggle($(this).is(topics)); }); });
Comments
Post a Comment