开发者

remove works but not hide?

开发者 https://www.devze.com 2023-01-08 04:44 出处:网络
creating a filter for a select menu and having a few problems! the first one is $(\"#filterContentMenu option:contains(a)\").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

精彩评论

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