order of onclick events
Posted
by NicoF
on Stack Overflow
See other posts from Stack Overflow
or by NicoF
Published on 2010-05-06T12:54:18Z
Indexed on
2010/05/06
12:58 UTC
Read the original article
Hit count: 322
I want to add a jquery click event to href's that already have an onclick event. In the example below the hard coded onclick event will get triggered first. How can I reverse that?
<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>
© Stack Overflow or respective owner