<form action="blah">
<table>...</table>
<table>
<tr>...</tr>
<tr>
<td>...<td>
<td> **some text that changes** </td>
Given the above html structure, how do i get the text that changes , using jQuery
So i want jquery to search like this: -look for form that has atrribute action="blah" -select the 2nd table of the form -select the 2nd row (tr) of the table -select the 2nd cell (td) of the row -give me the text
This will help me greatly understanding jquery... i'm new to it.
Something like $('form[action="blah"]').tables(2).rows(2).cells(2).text but this is not a valid jquery match
So you want the second table cell in the second table row of the second table? The eq
function can make this easy
DEMO
var text = $("table:eq(1) tr:eq(1) td:eq(1)").text();
Also note that you didn't close this table cell correctly:
<td>...<td>
should be
<td>...</td>
EDIT
If there are other tables on the page, and you want to make sure you get the second on in the form, then add the form to your selector:
var text = $("form[action='blah'] table:eq(1) tr:eq(1) td:eq(1)").text();
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