09-27-2008, 07:29 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Your code will execute as soon as the browser sees it, but at that time there are no <a> elements to attach the click function to! You need to wait until the HTML document is all downloaded to safely attach event handlers like this.
JavaScript Code:
jQuery(function(){
$("a").click(function(event){ alert("As you can see, the link no longer took you to jquery.com"); event.preventDefault(); });
});
|
|
|
|