[ad_1]
So I have a basic table structured:
<tbody>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody> etc....
I’m trying to target a link <a>
element in one cell only if the cell above it does or does not contain a word. For example:
<tbody>
<tr>
<td></td>
<td><b>Fire Sale!</b></td>
</tr>
<tr>
<td></td>
<td><a href="something">linktext</a></td>
</tr>
/tbody>
So I’d want to target the <a>
only if the cell above it contains “Fire Sale!” or perhaps does not contain a word, I have scenarios both ways.
The problem is no matter what I do I can’t keep the conditional axes to find the cell right above, another <a>
next to (<td>
immediately above) the <a>
we want is also targeted e.g.
<tbody>
<tr>
<td></td>
<td><b>Fire Sale!</b></td>
</tr>
<tr>
<td><a href="somethingelse">link I don't want</a></td>
<td><a href="something">linktext</a></td>
</tr>
/tbody>
I’ve tried stuff like:
//tr/td/b/a[@href]/ancestor::tbody/tr/td/b[contains(text(),'Fire Sale!')]
But no matter what, because of the odd relationship between tr and td I always end up getting an affirmative conditional. That is, they share the same ancestor tree structure for the most part and targeting back down to the <td>
above my main target seems impossible. Is there some way to use variables or I feel count() might help but I’m just not sure of the syntax for the whole thing.
Any ideas?
[ad_2]