Pull text <TD:last> based on content of the first <TD:first>
I have a table with a dozen rows, one of which is:开发者_如何学运维
<TR><TD>
<B>Order Date</B> </TD><TD> [foo] </TD></TR>
<TR><TD>
and i want to assign the value of the last cell to a var.
thx
try:
var text = $('td:contains("Order Date")').parent().children('td:last').text();
Your question is somewhat unclear.
You can get the last child of a row for which the first child contains Order Date
like this:
$('tr:has(td:first-child:contains("Order Date")) td:last-child').text()
cleaner:
var cellText = $('td:contains("Order Date")').nextAll(':last').text();
精彩评论