Hello...">

Why is my hidden <tr> not hidden?

I have this simple html markup created from classic asp:

<table>
  <tr class="trClass">
    <td>Hello </td>
  </tr>
  <tr class ="trClass">
    <td>World!</td> 
  </tr>
</table>

If I set tr belonging to Hello to hide () using jQuery, it hides. Good!

But, when I use this $ ('. TrClass: visible'). each (function () {alert ('visible')}); it shows the output of "visible" twice.

Why is this?

My problem is that im filters the table in a column with a select box. But after filtering, I need to perform some calculations on the rows that are visible in the table, but now I get all the rows.

Any ideas?

/ Daniel

+5
source share
4 answers

:visible display, :hidden, 1.3.2 :

... CSS- "none" / "", 0, 0, .

:

$('.trClass:not(:hidden)').each(function() { 
    alert('visible'); 
});

$('.trClass').each(function() { 
    if(!$(this).is(':hidden')) {
        alert('visible'); 
    }
});

$('.trClass').filter('not:(:hidden)').each(function() { 
    alert('visible');
});

hide display="none". jQuery 1.3.2 :

jQuery 1.3.2 -offset offsetWidth offsetHeight 0.

, :visible , , , CSS display none, , :hidden style="display:none", :hidden .

+13

. 1.3.2, .

Resig:

'tr' , IE

, ...

+4

Not sure if this matters, but doesn't hide () the value display: none;, and not visible: hidden? This means that the hidden line is still visible, it just does not appear ...

+2
source

most likely your trClass will encounter a mapping: none, which sets .hide (). when a tag has both a class attribute and a style attribute just for that. You should carefully monitor your trClass and display: material from it.

0
source

All Articles