< option>与显示:无;不适用于IE [英] <option> with display:none; does not work on IE

查看:94
本文介绍了< option>与显示:无;不适用于IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在option元素中有一些style='display:none',它在Chrome上运行良好,并且我意识到它在IE上不起作用.

I have some style='display:none' in the option element, it work well on Chrome and I realise it does not work on IE.

<select>
 <option style="display:none;">One</option>
 <option>Two</option>
 <option style="display:none;">Three</option>
 <option>Four</option>
</select>

使用jQuery,如何遍历该选项以查找display:none并删除元素<option>?

Using jQuery, how to loop through the option to find display:none and remove the elements <option>?

推荐答案

这似乎对我有用:

http://jsfiddle.net/PP4AP/1/

$('select option').each(function(){

    if(this.style.display == 'none')
    {
        $(this).remove();
    }

});

这篇关于&lt; option&gt;与显示:无;不适用于IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆