Sorry about the cranky title, here’s the example:
<table>
<tr>
<th class="hey-1-aa"></th>
</tr>
<tr>
<th class="hey-2-aa"></th>
</tr>
<tr>
<td class="hey-1-bb"></tr>
</tr>
<tr>
<td class="hey-2-bb"></tr>
</tr>
</table>
Is there any better way to selects all the THs/TRs start with the class prefix “hey-2-“, with something less verbose than $('th[class^="hey-2"], td[class^="hey-2"]')?
You could try this:
That is, select any children of each tr element that have a class starting with “hey-2”.
Demo: http://jsfiddle.net/CCuxX/
(Or for markup exactly like that in the question:
$('tr:odd > *'))I know that obviously you’ve simplified your markup for the question, but as it stands you seem to be using classes as unique identifiers – if so you should use ids.