Created
March 25, 2014 10:41
-
-
Save bennadel/9758999 to your computer and use it in GitHub Desktop.
Preventing Default Actions In A Bubbled Event In jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<title>Event Bubbling In jQuery</title> | |
<script type="text/javascript" src="jquery-1.3.2.js"></script> | |
<script type="text/javascript"> | |
// When the DOM is ready to be interacted with, | |
$(function(){ | |
// Bind click event handling on the UL. This will allow | |
// us to handle both link and LI clicks in one place | |
// by leveraging event bubbling. | |
$( "ul" ).click( | |
function( objEvent ){ | |
// Return FALSE to prevent the default. | |
return( false ); | |
} | |
); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1> | |
Event Bubbling In jQuery | |
</h1> | |
<ul> | |
<li> | |
Go to <a href="http://www.t-nation.com">T-Nation</a> | |
</li> | |
<li> | |
Go to <a href="http://www.cfbloggers.com">CF Bloggers</a> | |
</li> | |
<li> | |
Go to <a href="http://www.nycfug.com">NY CFUG</a> | |
</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment