Wednesday, October 26, 2011

How to remove option from selectbox options using Jquery

Here I am explaining how to remove an option from selectbox or combobox  options list using Jquery. Jquery is a powerful javascript library that provides a lot of predefined functions to achieve our needs.

For removing the option, using remove function(remove()).  
Add following script in onload function.

$("#selectboxid option[value='value']").remove();


selectboxid = ID of your selectbox
value = value of the option which you want to remove.


$(document).ready(function()){
   $("#select-id option[value='0']").remove();
});


Here option value 0 is removed while  the form load.

http://api.jquery.com/remove/

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Maintained by Web Themes