jQuery: How to count the number of elements which “display” isn't “none”?

前端 未结 3 445
野的像风
野的像风 2021-01-02 02:07

I use show() and hide() to show and hide rows in a table.

How could I count the number of non-hidden rows (more accurately, rows with

相关标签:
3条回答
  • 2021-01-02 02:17

    Try this:

    $('tr:not([style*="display: none"])').length
    

    Example http://jsfiddle.net/infernalbadger/7LvD5/

    0 讨论(0)
  • 2021-01-02 02:38

    Filter your rows based on their actual CSS property:

    $('tr').filter(function() {
        return $(this).css('display') !== 'none';
    }).length;
    
    0 讨论(0)
  • 2021-01-02 02:41

    jquery selector to count the number of visible table rows?

    Change !== to ===

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