jquery如何重新分离选项上的分离

时间:2010-07-03 09:18:07

标签: jquery select option detach

我需要关于以下代码的帮助:http://jsfiddle.net/8PsdE/

<SELECT ID="pizzasize" NAME="pizzasize">
<OPTION VALUE="s">small
<OPTION VALUE="m">medium
<OPTION VALUE="l">large
</SELECT>

    $(function() {
   $('#pizzasize > option[value*="m"]').detach();
});

如何重新添加分离选项? Thx提前......

1 个答案:

答案 0 :(得分:1)

获取对您选择的选项的引用,然后您可以使用该引用分离它们或对它们执行任何其他操作:

$(function() {
  var theOptions = $('#pizzasize > option[value*="m"]');
  theOptions.detach();

  // Do other things with theOptions
});
相关问题