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

前端 未结 3 467
野的像风
野的像风 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:38

    Filter your rows based on their actual CSS property:

    $('tr').filter(function() {
        return $(this).css('display') !== 'none';
    }).length;
    

提交回复
热议问题