I would to remove all the options (but the first one with value = 0) from a select with id="myid".
I wouldn't to use empty() and then append().
If it is the first element, use gt and remove
$("#myid option:gt(0)").remove();
use attribute selector
$('#myid option[value!="0"]').remove();
use filter
$('#myid option').filter(
function () {
return parseInt(this.value,10) !== 0;
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With