다음은 내가 가지고있는 것입니다. 나는 몇 가지를 시도했지만 내가 뭘 잘못 알아낼 수 없습니다 ...JQuery 학부모() 다음 호
<div class="VoteControls" runat="server" visible='<%# User.Identity.IsAuthenticated %>'>
<img style="cursor: pointer; cursor: hand;" src='<%# (bool)Eval("skull") ? "images/skull.png" : "images/skull-bw.png" %>' alt="Vote Down" class="votedown" title='<%# Eval("entry.ID") %>' />
<img style="cursor: pointer; cursor: hand;" src='<%# (bool)Eval("heart") ? "images/heart.png" : "images/heart-bw.png" %>' alt="Vote Up" class="voteup" title='<%# Eval("entry.ID") %>' />
</div>
그리고 JQuery와 :
$(document).ready(function() {
$(".voteup").click(function() {
var id = $(this).attr("title");
var userID = $("HiddenFieldUserID").val();
var skullButton = $(this).parent().closest('.votedown');
alert(skullButton.attr("src"));
registerUpVote("up", id, $(this), skullButton, userID);
});
$(".votedown").click(function() {
var id = $(this).attr("title");
var userID = $("HiddenFieldUserID").val();
var heartButton = $(this).parent().closest('.voteup');
alert(heartButton.attr("src"));
registerDownVote("down", id, heartButton, $(this), userID);
});
});
.voteup의 IMG 클릭 할 때 목표는, 동일한 VoteControls div에서 해당 .votedown img를 찾으십시오. 위의 div는 DataList의 일부이므로 한 페이지에 여러 개의 항목이 있습니다.
그래서 작동하지 않는 부분은 다음과 같습니다
var skullButton = $(this).parent().closest('.votedown');
SO 복제본을 쓰고 있습니까? – SLaks
Nope. 위/아래 (싫어함과 같이) 만 있다는 점에서 비슷한 투표 시스템이 필요합니다. 그러나 SO는 기능 측면에서 내가 가장 좋아하는 웹 사이트이므로, 내가하는 일에 적용 할 수있는 모든 것이 승리입니다. = D – Jason