I have a div with two tables. I want to select the rows from only the one table having N rows.
In XPath I would use:
//div[@class="div1"]/table[count(tr) = 2]/tr
Is there a jQuery selector expression that will do the same thing?
Here's the HTML snippet:
<div>
<div class="div1">
<ul>
<li>Line 1</li>
</ul>
<ul>
<li>Line 1</li>
<li>Line 2</li>
</ul>
</div>
</div>
I was hoping this could be done in a single jQuery selector expression (e.g., understood in this Interactive JQuery Tester ). My starting point is:
'div.div1 ul li'
but that also selects the rows from the first table which only has 1 row.
Of course, the "right way" to do this is add IDs or something else to the HTML so that the table can be identified uniquely, however in this instance I have no control over the HTML I am grabbing the data from. The only way I can tell which of the multiple tables to use is from the row count.