Remove select options with a value greater than 0

I would like to remove all parameters (but the first with value = 0) from select with id = "myid".

I would not use empty () and then append ().

+4
source share
1 answer

If this is the first item, 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; } ); 
+10
source

Source: https://habr.com/ru/post/1445145/


All Articles