Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

count of tr with style property empty [closed]

Here is my html

<table id="tbl1">
  <tbody >
         <tr class="hide_grid_header"></tr>
         <tr style="display: none;"></tr>
         <tr style="display: none;"></tr>
          <tr ></tr>
         <tr style=""></tr>
         <tr ></tr>
         <tr style=""></tr>
         <tr ></tr>
       <tr style="display: none;"></tr>
  </tbody>
</table>

From this, I want count of tr which dont have style property OR with style=" " property.

i'm using below code, but its giving me count as 8 instead of 5.

 var docs = jQuery("#tbl").find('tbody').find('tr:visible');
alert(docs.length);
like image 346
Syed Afroz Avatar asked Mar 15 '13 07:03

Syed Afroz


2 Answers

$('tr').filter(function(){
    return !$(this).attr('style');
}).length;
like image 90
gdoron is supporting Monica Avatar answered Oct 13 '22 13:10

gdoron is supporting Monica


var len = $('tr').filter(function(){
      return !$(this).attr('style');
}).length;

http://jsfiddle.net/6pHt6/

like image 44
undefined Avatar answered Oct 13 '22 11:10

undefined