Tutorial :JQuery: Hide options of select according to option value



Question:

given following html

<select name="IBE1$IBE_NurFlug1$ddl_Abflughafen" id="IBE1_IBE_NurFlug1_ddl_Abflughafen" class="dropdownlist" style="width: 99%;">  <option value="Antalya;TR">Antalya</option>  <option value="Berlin;DE">Berlin</option>  <option value="Duesseldorf;DE">Duesseldorf</option>  <option value="Frankfurt;DE">Frankfurt</option>  <option value="Hamburg;DE">Hamburg</option>  <option value="Hannover;DE">Hannover</option>  <option value="Köln-Bonn;DE">Köln-Bonn</option>  <option value="Leipzig;DE">Leipzig</option>  <option value="München;DE">München</option>  <option value="Stuttgart;DE">Stuttgart</option>  

How can I hide all options with ;TR in the value?

thx a lot in advance, greetings


Solution:1

Try

$("select > option[value*='TR']").remove()  

EDIT:

Or if you know that 'TR' is always at the end, then

$("select > option[value$='TR']").remove()  

Not sure how much more efficient the above is compared to searching the entire value attribute.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »