开发者

remove works but not hide?

creating a filter for a select menu and having a few problems!

the first one is

$("#filterContentMenu option:contains(a)").hide();
开发者_JAVA技巧

doesn't work but

$("#filterContentMenu option:contains(a)").remove();

does.

Actually this only seem to be a problem in safari! Works in firefox?


.hide() sets an element's display to none. You can't set an <option> to display: none, it won't work in all browsers. You can remove them and retain a reference to them, though:

var removed = $("#filterContentMenu option:contains(a)").remove();

// later that day...
removed.appendTo("#filterContentMenu");


"Hiding" (setting to display: none) options isn't very well supported in several browsers. It is really better to delete and recreate them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜