代码之家  ›  专栏  ›  技术社区  ›  Jourkey

jquery全选br显示:无;

  •  12
  • Jourkey  · 技术社区  · 15 年前

    如何根据元素的css选择元素?

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

    谢谢。

    6 回复  |  直到 6 年前
        1
  •  34
  •   Tim Banks    15 年前

    你可以试试:

    $("br").filter(function() { return $(this).css("display") == "none" })
    
        2
  •  11
  •   jesal    12 年前

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

    $("br[style$='display: none;']")
    
        3
  •  5
  •   mauris    12 年前

    使用 filter .

    $("br").filter(function () {
        return $(this).css("display") == "none";
    });
    
        4
  •  0
  •   Adam Bard    15 年前

    使用jQuy.MaP:

    var brs = $('br');
    jQuery.map(brs, function(elem, i){
        if(elem.css('display') == 'none')
            return elem;
        return null;
    });
    
        5
  •  0
  •   Konrad Viltersten    12 年前
    $("br").filter(function() {
      return $(this).css("display") == "none";
    })
    

    很有魅力。

        6
  •  0
  •   Purnil Soni    11 年前

    像这样的怎么样:

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