Accessing Element Count and Values Within a Hidden Div
Posted
by Tegan Snyder
on Stack Overflow
See other posts from Stack Overflow
or by Tegan Snyder
Published on 2010-03-08T20:32:00Z
Indexed on
2010/03/08
20:36 UTC
Read the original article
Hit count: 262
I'm having trouble grabbing the TR count in JQuery of a table that inside a DIV set to be hidden.
Here is an example:
<div id="questions" style="display: none;">
<table id="tbl_questions">
<thead>
<tr>
<th>Question</th>
<th>Weight</th>
</tr>
</thead>
<tbody>
<tr id="q0">
<td id="td_question0">Some Question 0</td>
<td id="td_wieght0">Some Weight 0</td>
</tr>
<tr id="q1">
<td id="td_question1">Some Question 1</td>
<td id="td_wieght1">Some Weight 1</td>
</tr>
</tbody>
</table>
</div>
Note the table is within the containing div. It's set to display: none. When I try to run this JQuery code it returns 0.
var question_count = $("#tbl_questions> tr").size();
alert(question_count);
Any ideas?
I'm try to locate the count so I can then build an array of each question and weight in the table. Since the ID's provide me with an index this should be simple, but is the fact that it is contained in a hidden DIV going to be a problem just as the above question?
Thanks, Tegan Snyder
© Stack Overflow or respective owner