$(&#; #id option")。hide();不在safari / chrome上工作? [英] $("#id option").hide(); not working on safari/chrome?
问题描述
相同:
$(#id option)。show();
我很惊讶。我认为我的代码出了问题。我尝试了一个空白的html:
< select id =name>
< option> 1< / option>
< option> 2< / option>
< / select>
Javascript:
$(#name option)。hide();
< a href =http://jsfiddle.net/kgLkt/ =nofollow> http://jsfiddle.net/kgLkt/
它的作用就像一个用firefox的魅力,但不是在safari和chrome上!
是否有替代品?!
编辑:
我需要隐藏/显示出现在列表中的选项(或其中的一部分)。
隐藏:
var myOpts = $(#id option)。detach );
显示:
$(#id option)。append(myOpts);
与 .remove()
不同, .detach()
保留所有与被删除元素相关联的jQuery数据。
Same for:
$("#id option").show();
I'm just surprised. I thought that something went wrong with my code. I tried it with a blank html:
<select id = "name">
<option>1</option>
<option>2</option>
</select>
Javascript:
$("#name option").hide();
It works like a charm with firefox, but not on safari nor chrome!
Is there a substitute?!
EDIT: I need to hide/show the option (or some of them) from appearing in the list.
To hide:
var myOpts = $("#id option").detach();
To show:
$("#id option").append(myOpts);
As opposed to .remove()
, .detach()
keeps all jQuery data associated with the removed elements.
这篇关于$(&#; #id option")。hide();不在safari / chrome上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!