jquery - Remove Particular Option from select Tag -


i have following combobox , want remove option value null (value='') using jquery

<option value=''>--select--</option> <option value ='1'>one</option> <option value ='2'>two</option> <option value ='3'>three</option> <option value ='4'>four</option> 

expected combo option:

<select name='x' id='x'>     <option vlaue=''>--select--</option> </select> 

if understand correctly saying want remove options value not null, following work:

$("#x").children("option").not("[value='']").remove(); 

if it's reverse, then:

$("#x").children("[value='']").remove(); 

but first have fix misspellings in code:

<select name='x' id='x'>     <option value=''>--select--</option>     <option value='1'>one</option>     <option value='2'>two</option>     <option value='3'>three</option>     <option value='4'>four</option> </select> 

note value , /select misspelled in example, , that'll keep code working.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -