Jquery select option removed

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/lm9521/article/details/88062545
<select id = "type" name="type">
    <option value=""></option>
</select>

1. Remove option in select

以 id

$("#type").html("");

$("#type").find("option").remove();

$("#type").empty();

以name

$("select[name='type']").html("");

$("select[name='type']").remove();

$("select[name='type']").empty();

2. Remove all but the first option except under select

  $("select[name='type'] option:gt(0)").remove();

 

Guess you like

Origin blog.csdn.net/lm9521/article/details/88062545