lilbiscuit lilbiscuit - 1 month ago 7
jQuery Question

How to select td when you know th text with jquery

I have a table containing rows with exactly one th and one td like this:

<tr>
<th>Phone Number</th>
<td>555-555-1212</td>
</tr>


I need to select the td cell (and replace the html) by using the th text "Phone Number". I can get the th cell with

$('th:contains("Phone Number")')


but I can't figure out how to select the corresponding td cell.

Answer
$('th:contains("Phone Number")').next('td');
Comments