If your td
is "bare" (i.e. not wrapped in a jQuery object), you can access its id
attribute directly:
if (myTD.id.indexOf("34a") > -1) {
// do stuff
}
If it is in a jQuery object, you'll need to get it out first:
if (jMyTD[0].id.indexOf("34a") > -1 {
// do stuff
}
The indexOf
function finds the offset of one string within another. It returns -1 if the first string doesn't contain the second at all.
Edit:
On second thought, you may need to clarify your question. It isn't clear which of these you're trying to match "34a" against:
<td id="1234abcd">blahblah</td>
<td id="blahblah">1234abcd</td>
<table id="1234abcd"><tr><td>blahblah</td></tr></table>
<table id="blahblah"><tr><td>1234abcd</td></tr></table>