I got a very simple Table with only two rows.
I was thinking what is the best way to get the value from the TD with ID "row2".
<Table id="testing>
<tr>
<th>
</th>
<td id="row1">hello</td>
</tr>
<tr>
<th>
</th>
<td id="row2">world</td>
</tr>
</table>
Here is my attempt:
$(document).ready(function(){
var r=$("#testing":row2).val();
alert(r);
});
But I couldn't see any message pop up.
What shall I do in the JQuery code if I want to specify the Table ID along with the TD ID?
var r=$("#testing":row2).text();
var r=$("#testing").children("row2").text();
This will do it for you:
var r = $("#testing #row2").text();
alert(r);
In action here for your viewing pleasure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With