I have bits of horrible code I have to deal with
...
<div class="container">
...
<tr>
<td width="100" height="50">
<a class="swaps"><img src="http://www.blah.jpg" alt="Some Title" id="1"></a></span></td>
</tr>
<tr>
<td width="100" height="50">
<a class="swaps"><img src="http://www.blah2.jpg" alt="Another title" id="2"></a></span></td>
</tr>
</div>
If I use
var thisone = $("#container .swaps:first")
to select the first one (with id 1) why do I have trouble selecting
thisone.next()?
The HTML is the real one? I don’t see any element with id “container” and you’re doing
$("#container .swaps:first")Also, if it’s the real HTML, you should fix it a little (close the img tag, and add the opening tag for the span before the </TD>)
Supposing that your HTML is OK this should work for your scenario.
The IMG is not sibling of the anchor, is a child.