Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
174
rated 0 times [  176] [ 2]  / answers: 1 / hits: 15914  / 10 Years ago, fri, january 30, 2015, 12:00:00

I am trying to delete two options from a select tag using jQuery using the following code



 $(#selectionid option[value='option1']).remove();
$(#selectionid option[value='option2']).remove();


Is there any way to delete the two options at a time dynamically.


More From » jquery

 Answers
13

In a single line you can remove like



$('#selectionid option').filter('[value=option1],[value=option2]').remove();


Demo


[#68028] Wednesday, January 28, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gerardob

Total Points: 571
Total Questions: 115
Total Answers: 96

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;