Javascript Event How to - Verify Javascript event execution order








Question

We would like to know how to verify Javascript event execution order.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.4.2.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--  ww w.j  av a 2s  .c  o m-->
    $('#anchor').click(function(){
        console.log('JQuery after :(');
    });
});
</script>
</head>
<body>
  <a id="anchor" href="#"
    onclick="alert('OnClick first!'); return false;">Click me</a>
</body>
</html>

The code above is rendered as follows: