I want to be able to hide certain options in html "select", which have value greater that a specific variable:
This is a simple "select" in my html with all options initially available:
<select class="form-control" id="results_per_page">
<option value="4">4</option>
<option value="8">8</option>
<option value="12">12</option>
<option value="16">16</option>
<option value="20">20</option>
<option value="28">28</option>
<option value="40">40</option>
<option value="80">80</option>
<option value="120">120</option>
</select>
Now, my script looks like this:
var itemsFound = "22"; //that's an example -can be any number
// I want to hide the options that are greater than "itemsFound"
$('#results_per_page').find('option[value > "'+itemsFound+'"]').hide();
The line above returns "Uncaught Error: Syntax Error, unrecognized expression: option[value > "22"]
When I use the "equal" though, it works:
$('#results_per_page').find('option[value = "40"]').hide(); //the option with value "40" is indeed hidden
Any ideas of how could this implemented?