JQuery Selector - Finding an img in a table
Cant seem to get the following to find the 'skull' button when the 'heart' button is clicked...
Here is the JQuery...
$(".voteup").click(function() {
var id = $(th开发者_如何学编程is).attr("title");
var userID = $('[id$=HiddenFieldUserID]').val();
var ipAddress = $('[id$=HiddenFieldIPAddress]').val();
var skullButton = $(this).parent().siblings(".votedowntd").children("votedown");
registerUpVote("up", id, $(this), skullButton, userID, ipAddress);
});
And the HTML...
<table width="200px">
<td width="35px" class="votedowntd">
<img src='<%# (bool)Eval("skull") ? "images/skull.png" : "images/skull-bw.png" %>' alt="Vote Down" class="votedown" title='<%# Eval("entry.ID") %>' />
</td>
<td width="130px" style="text-align: center;">
Num Votes Goes Here
</td>
<td width="35px" class="voteuptd">
<img src='<%# (bool)Eval("heart") ? "images/heart.png" : "images/heart-bw.png" %>' alt="Vote Up" class="voteup" title='<%# Eval("entry.ID") %>' />
</td>
<tr>
</tr>
</table>
So basically what I need to do is when one img is clicked, I need to find the other one.
Why is what I have not working? Is there a better way to do this?
This should do it:
$(this).closest('table').find('.votedown');
精彩评论