Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery select remove option

Tags:

jquery

I'm currently using this successfully to remove an option

    $("select#select_gender option[value='initial']").remove();

Is there a way remove an option without adding to the selector - like below?

    $('select#select_gender').val('initial').remove();

thx

like image 905
Adam Avatar asked Sep 11 '11 00:09

Adam


1 Answers

$("select#select_gender option").filter("[value='initial']").remove();

I believe that does it.

or per your latest comment:

var sel = $("select#select_gender");
sel.find("option[value='initial']").remove();

PS sorry for so many edits :(

like image 84
Joseph Marikle Avatar answered Sep 28 '22 09:09

Joseph Marikle