how to check if row is invisible

A

adeveloper

I have a tbody which is invisible (CSS set to display none). When I am
going through all rows in the whole table, how do I find out which
rows are visible to the user and which are invisible?

All invisible rows are in invisible tbodies. Maybe it is possible to
check if parent (tbody) is visible to determine if a row is visible?

It appears that FireFox does not support current style property.
 
D

David Mark

I have a tbody which is invisible (CSS set to display none). When I am
going through all rows in the whole table, how do I find out which
rows are visible to the user and which are invisible?

How did they get to be "invisible?"
All invisible rows are in invisible tbodies. Maybe it is possible to
check if parent (tbody) is visible to determine if a row is visible?

It appears that FireFox does not support current style property.

But, as with most modern browsers (except IE), it supports
getComputedStyle. IE's "current style" is not appropriate for this as
the cascaded style may not match the computed style.
 
B

Bart Van der Donck

adeveloper said:
I have a tbody which is invisible (CSS set to display none). When I am
going through all rows in the whole table, how do I find out which
rows are visible to the user and which are invisible?

All invisible rows are in invisible tbodies. Maybe it is possible to
check if parent (tbody) is visible to determine if a row is visible?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Visible and invisible rows</title>
<script type="text/javascript">
function visible_rows() {
var r = '';
var obj = document.getElementById('t').getElementsByTagName('tr')
for (var i = 0; i < obj.length; ++i) {
r += 'Row ' + (i+1) + ' = ';
obj.parentNode.style.display == 'none' ? r += 'invisible\n'
: r += 'visible\n'
}
alert(r)
}
</script>
</head>
<body onLoad="visible_rows();">

<table border="1" id="t">
<tbody style="display: none">
<tr><td>one</td></tr>
<tr><td>two</td></tr>
</tbody>

<tbody>
<tr><td>three</td></tr>
<tr><td>four</td></tr>
</tbody>

<tbody style="display: none">
<tr><td>five</td></tr>
</tbody>
</table>

</body>
</html>

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top