2010-03-08 68 views
0

不能似乎得到以下找到「骷髏」按鈕被點擊的「心臟」按鈕時...jQuery選擇 - 尋找一個img在表

這裏是JQuery的...

  $(".voteup").click(function() { 
       var id = $(this).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); 
      }); 

和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> 

所以基本上我需要做的就是當點擊一個IMG,我需要找到另一個。

爲什麼我沒有工作?有一個更好的方法嗎?

回答

2

這應做到:

$(this).closest('table').find('.votedown'); 
+0

真棒。作品。謝謝。 – Jason 2010-03-08 08:42:50