So this is the working HTML for adjusting the zoom.
What I need to do now is how to hide the 200 option with an if condition using Javascript.
So if a variable is greater than the 200 option, I need to hide it.
EDIT:
I was wrong explaining it, so if a variable is greater than another variable, I need to hide the 200 option and display the 100, 300, and 400.
<div id="zoomAdjuster' class="centerAlign">
<span>Zoom</span>
<select name="chooseAZoom">
<option value="100" selected>100</option>
<option value="200">200</option>
<option value="300">300</option>
<option value="400">400</option>
</select>
</div>
Please help, I don’t know much about this language. Thank you.
2
Answers
You can select the
select
using any document query method and then select the options. Then iterate the options and check for the value. If value is grater than 200 then add a class to hide itYou can also remove the
option
tags from the DOM. By:select
tag from the DOM, then get its childrenoption
tags, put those in an array with the spread syntax.option
tag with thevalue
of 200, if your variable is larger than 200. Else keep the array.option
tags insideselect
, then loop through the filtered array and appending the option tags back toselect