jquery选择所有br with display:none;
如何根据css选择元素?
我需要选择带有内联样式显示的br:none。 这与br:hidden不同,因为它选择了以其他方式隐藏的元素,我不希望这样。
谢谢。
你可以尝试:
$("br").filter(function() { return $(this).css("display") == "none" })
另一种方法是使用jQuery的属性选择器:
$("br[style$='display: none;']")
使用filter 。
$("br").filter(function () { return $(this).css("display") == "none"; });
使用jQuery.map:
var brs = $('br'); jQuery.map(brs, function(elem, i){ if(elem.css('display') == 'none') return elem; return null; });
$("br").filter(function() { return $(this).css("display") == "none"; })
奇迹般有效。
这样的事情怎么样:
$(document).ready(function() { $("div:hidden").each(function() { if ($(this).css("display") == "none") { // do something } }); });