jquery select all br with display:none;

后端 未结 6 801
梦毁少年i
梦毁少年i 2020-12-15 07:15

How do I select an element based on its css?

I need to select a br with inline style display:none. This is not the same thing as br:hidden, because that selects elem

相关标签:
6条回答
  • 2020-12-15 07:23

    Using filter.

    $("br").filter(function () {
        return $(this).css("display") == "none";
    });
    
    0 讨论(0)
  • Another way to do this would be to use jQuery's attribute selector:

    $("br[style$='display: none;']")
    
    0 讨论(0)
  • 2020-12-15 07:29

    You could try:

    $("br").filter(function() { return $(this).css("display") == "none" })
    
    0 讨论(0)
  • 2020-12-15 07:48

    How about something like this:

    $(document).ready(function() {
      $("div:hidden").each(function() {
        if ($(this).css("display") == "none") {
            // do something
        }
      });
    });
    
    0 讨论(0)
  • 2020-12-15 07:48

    Use jQuery.map:

    var brs = $('br');
    jQuery.map(brs, function(elem, i){
        if(elem.css('display') == 'none')
            return elem;
        return null;
    });
    
    0 讨论(0)
  • 2020-12-15 07:49
    $("br").filter(function() {
      return $(this).css("display") == "none";
    })
    

    Works like a charm.

    0 讨论(0)
提交回复
热议问题