开发者

Hiding listbox option in IE with jQuery?

开发者 https://www.devze.com 2023-03-08 12:33 出处:网络
I finished some jQuery code to manipulate showing/hiding of listbox items and then found it doens\' work in IE 8.This simplified example(assume there\'s a listbox on the page) wor开发者_StackOverflowk

I finished some jQuery code to manipulate showing/hiding of listbox items and then found it doens' work in IE 8. This simplified example(assume there's a listbox on the page) wor开发者_StackOverflowks fine for hiding all options of a listbox in Firefox, but not for IE. Any ideas why this doesn't work?

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> 
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
  $("option").hide();
});
</script>


You can't hide option elements in Internet Explorer. You need to remove them instead:

$('option').detach();
0

精彩评论

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

关注公众号