Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
id="myid" の選択からすべてのオプション (ただし、値 = 0 の最初のオプション) を削除します。
empty() を使用してから append() を使用することはありません。
最初の要素の場合は、gt を使用して削除します
$("#myid option:gt(0)").remove();
属性セレクターを使用する
$('#myid option[value!="0"]').remove();
フィルタを使用
$('#myid option').filter( function () { return parseInt(this.value,10) !== 0; } );