I currently have a total of four filter buttons on my website, and I only want two of them to be visible at any given time. To achieve this, I labeled the first set of buttons as .switch1
and the second set as .switch2
. Now, I've added a 'switch filter' button that, when clicked by the user, will toggle the display properties of these buttons; changing .switch1
from display:block
to none
, and .switch2
from display:none
to block
.
<div class="switch2">
<label>Year</label>
<select class="px-3 py-1 form-select bg-btn" aria-label="Default select example" style="font-size: 14px;">
<option selected>2022</option>
<option value="1">2021</option>
<option value="2">2020</option>
<option value="2">2019</option>
<option value="2">2018</option>
<option value="2">2017</option>
<option value="2">2016</option>
</select>
</div>
<div class="switch1">
<label>From:</label>
<input class="px-3 py-1 fr-to bg-btn" type="date" name="" id="" style="font-size: 14px;">
</div>
</div>
<div class="month-select col-2">
<div class="switch2">
<label>Month</label>
<select class="px-3 py-1 form-select bg-btn" aria-label="Default select example" style="font-size: 14px;">
<option selected>January</option>
<option value="1">February</option>
<option value="2">March</option>
<option value="2">April</option>
<option value="2">May</option>
<option value="2">June</option>
<option value="2">July</option>
<option value="2">August</option>
<option value="2">September</option>
<option value="2">October</option>
<option value="2">November</option>
<option value="2">December</option>
</select>
</div>
<div class="switch1">
<label>To:</label>
<input class="px-3 py-1 fr-to bg-btn" type="date" name="" id="" style="font-size: 14px;">
</div>
</div>
<div class="ms-5 d-flex flex-column justify-content-end">
<div class=""><button class="btn-dark px-3 py-1 filterbtn">Filter</button></div>
</div>
You can view how the first and second sets of buttons appear on my site in the following screenshots: first buttons second buttons