Reputation: 16244
I want to remove few options, say, last three options, from a select box out of 5 options, using jquery
Below is the select box with 5 options tag
<select id="select">
<option>first</option>
<option>second</option>
<option>third</option>
<option>fourth</option>
<option>fifth</option>
</select>
UPDATE:
I tried this code
$("#select option:not(option:first, option:last)";
But that gave me uncaught exception in console
Upvotes: 1
Views: 599
Reputation: 709
you can use the following code to remove the latest items http://jsfiddle.net/QxmvC/
$('#select').children().slice(-3).remove();
Upvotes: 0
Reputation: 2136
What have you tried? I think the nth-child selector might be what you're looking for.
Upvotes: 0