Reputation: 1614
I was using this:
$('#' + tableID + "tr:first td:first")
To get my first cell, but there is potential the first cell isn't what I want. The cell I'm looking for is the first cell in the first row that has the class 'canEdit'. Any idea how to go about doing that?
Upvotes: 0
Views: 291
Reputation: 33661
So what you want is this from my understanding
$('#' + tableID + " tr:first td.canEdit:first")
// gets "first cell" in the "first row" that has class edit
Upvotes: 1
Reputation: 207511
Add a class to the tr. You should also limit to the tbody so it does not look in the thead or tfoot for the rows.
$('#' + tableID + " tbody tr.canEdit:first td:first")
Upvotes: 0
Reputation: 28695
Add your class to the selector.
$('#' + tableID + " tr.canEdit:first td:first")
Upvotes: 0
Reputation: 74046
Just add the respective class to your selector, like this:
If the row has to have the respective class:
$('#' + tableID + " tr.canEdit:first td:first")
Or if the cell has to have the class:
$('#' + tableID + " tr:first td.canEdit:first")
Also note the added space before the "tr" in the selector.
Upvotes: 3