jquery选择所有br with display:none;

Jou*_*key 14 jquery

如何根据css选择元素?

我需要选择带有内联样式显示的br:none.这与br:hidden不同,因为它选择了以其他方式隐藏的元素,我不希望这样.

谢谢.

Tim*_*nks 36

你可以尝试:

$("br").filter(function() { return $(this).css("display") == "none" })
Run Code Online (Sandbox Code Playgroud)


jes*_*sal 12

另一种方法是使用jQuery的属性选择器:

$("br[style$='display: none;']")
Run Code Online (Sandbox Code Playgroud)


che*_*rtz 5

使用过滤器.

$("br").filter(function () {
    return $(this).css("display") == "none";
});
Run Code Online (Sandbox Code Playgroud)