stopPropagation in action

example for article on http://stepansuvorov.com/blog

by Stepan Suvorov

HTML

<div id="demo">
    <a href="js4.it">Link</a>
</div>

CSS

.yellow{
background: yellow;
}

JavaScript

$('a').click(function(event){
	event.preventDefault();
	event.stopPropagation();
	console.log('You have clicked the link.');
});

$('#demo').click(function(){
	$(this).toggleClass('yellow');
	console.log('You have clicked the demo div.');
});