I have a page with 5 selects that all have a class name 'ct'. I need to remove the option with a value of 'X' from each select while running an onclick event. My code is:
$(".ct").each(function() {
$(this).find('X').remove();
});
Where am I going wrong?
For jquery < 1.8 you can use :
to remove a especific range of the select options.
Try this:
Or to be more terse, this will work just as well:
When I did just a remove the option remained in the ddl on the view, but was gone in the html (if u inspect the page)
Or just
Main point is that
find
takes a selector string, by feeding itx
you are looking for elements namedx
.It works on either option tag or text field:
if your dropdown is in a table and you do not have id for it then you can use the following jquery: