开发者

jquery how to re-detach a detach on option

开发者 https://www.devze.com 2023-01-06 09:17 出处:网络
I need help concerning following code: http://jsfiddle.net/8PsdE/ <SELECT ID=\"pizzasize\" NAME=\"pizzasize\">

I need help concerning following code: http://jsfiddle.net/8PsdE/

<SELECT ID="pizzasize" NAME="pizzasize">
<OPTION VALUE="s">small
<OPTION VALUE="m">medium
<OPTI开发者_Python百科ON VALUE="l">large
</SELECT>

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

How can I add the detached option back again? Thx in advance...


Get a reference to the options you have selected, then you can detach them or do anything else with them using that reference:

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

  // Do other things with theOptions
});
0

精彩评论

暂无评论...
验证码 换一张
取 消