6
jQuery 클릭 이벤트를 이미 onclick 이벤트가있는 href에 추가하려고합니다. 아래 예제에서 하드 코드 된 onclick 이벤트가 먼저 트리거됩니다. 어떻게 거꾸로 할 수 있습니까?onclick 이벤트 순서
<a class="whatever clickyGoal1" href="#" onclick="alert('trial game');">play trial</a>
<br />
<a class="whatever clickyGoal2" href="#" onclick="alert('real game');">real trial</a>
<p class="goal1">
</p>
<p class="goal2">
</p>
<script type="text/javascript">
$("a.clickyGoal1").click(function() {
$("p.goal1").append("trial button click goal is fired");//example
});
$("a.clickyGoal2").click(function() {
$("p.goal2").append("real button click goal is fired"); //example
});
</script>
그리고 때로는 여기에만 요소에 액세스하기 위해 다음 자바 스크립트 처리기를 "정상"설정 jQuery를 사용하는 예입니다 old 함수 내에서'this' 변수를 보존 할 필요가 있습니다. 그래서 해결책은'oldOnClick.call (link, e)'입니다. – TautrimasPajarskas