i have 2 drop downs to filter a list. as of now it only filters which drop down was used last. i want them to work together, so that someone clicks "weeks" drop down, all the li with that class show, and then clicks "workouts" drop down and it filters it even more.
$('select').change(function() {
var current = this.value;
if (current == 'all') {
$('#FilterContainer').find('li.all').show();
} else {
$('#FilterContainer').find('li').hide();
$('#FilterContainer').find('li.all.' + current).show();
}
return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p align="center"><font face="futura" size="20px">Pick your workout here:</font>
</p>
<div align="center">
<select style="font-size:20px" class="filterby">
<option value="">
<h5>Select Week</h5>
</option>
<option value="1">
<h5>Week 1</h5>
</option>
<option value="2">
<h5>Week 2</h5>
</option>
<option value="3">
<h5>Week 3</h5>
</option>
<option value="4">
<h5>Week 4</h5>
</option>
</select>
<select style="font-size:20px" class="filterby">
<option value="">
<h5>Select Workout</h5>
</option>
<option value="sw1">
<h5>Strength Workout #1</h5>
</option>
<option value="sw2">
<h5>Strength Workout #2</h5>
</option>
<option value="cw1">
<h5>Conditioning Workout #3</h5>
</option>
<option value="cw2">
<h5>Conditioning Workout #4</h5>
</option>
<option value="rw">
<h5>Recovery Workout</h5>
</option>
</select>
</div>
<div id="FilterContainer">
<ul>
<li class=" all 1 sw1" style="list-style:none; display:none">saasasasa
</div>
</li>
</ul>
</div>
<script>
$('select').change(function() {
var current = this.value;
if (current == 'all') {
$('#FilterContainer').find('li.all').show();
} else {
$('#FilterContainer').find('li').hide();
$('#FilterContainer').find('li.all.' + current).show();
}
return false;
});
</script>