jQuery jquery选择所有带有显示的br:无;

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1616006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:50:17  来源:igfitidea点击:

jquery select all br with display:none;

jquery

提问by Jourkey

How do I select an element based on its css?

如何根据其 css 选择元素?

I need to select a br with inline style display:none. This is not the same thing as br:hidden, because that selects elements that are hidden in other ways, and I don't want that.

我需要选择一个带有内联样式显示的 br:无。这与 br:hidden 不同,因为它选择以其他方式隐藏的元素,而我不想要那样。

Thanks.

谢谢。

回答by Tim Banks

You could try:

你可以试试:

$("br").filter(function() { return $(this).css("display") == "none" })

回答by jesal

Another way to do this would be to use jQuery's attribute selector:

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

$("br[style$='display: none;']")

回答by chelmertz

Using filter.

使用过滤器

$("br").filter(function () {
    return $(this).css("display") == "none";
});

回答by Adam Bard

Use jQuery.map:

使用 jQuery.map:

var brs = $('br');
jQuery.map(brs, function(elem, i){
    if(elem.css('display') == 'none')
        return elem;
    return null;
});

回答by spig

How about something like this:

这样的事情怎么样:

$(document).ready(function() {
  $("div:hidden").each(function() {
    if ($(this).css("display") == "none") {
        // do something
    }
  });
});

回答by Ardylles

$("br").filter(function() {
  return $(this).css("display") == "none";
})

Works like a charm.

奇迹般有效。