1

ドロップダウン メニューに新しいオプションを追加し、それを選択不可にしてリストの最初にする最良の方法は何ですか?

したがって、リストは次のようになります。

<select onchange="document.getElementById('product_configure_form').action = 'http://webshop.com/product/options/3603848/'; document.getElementById('product_configure_form').submit();" id="product_configure_option_22853" name="option[22853]">

  <option selected="selected" value="78619">Choose a size</option> // this is the new not selectable option
  <option selected="selected" value="78619">S</option>
  <option value="78620">M</option>
  <option value="78621">L</option>
</select>

オプションを追加する方法を知っています:

$('#product_configure_option_22853').append('<option value="Choose" selected="selected">{{ 'select your size' | t }}</option>');

しかし、どうすればそれを選択不可にしてリストの最初にすることができますか?

どんな助けでも大歓迎です!

4

2 に答える 2

3

.prepend() を使用

$('#product_configure_option_22853').prepend('<option value="Choose" disabled="disabled">{{ 'select your size' | t }}</option>');
于 2013-07-04T20:36:39.513 に答える