stopPropagation in action

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

by AJIEKCEU

HTML

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

CSS

.yellow{
background: yellow;
}

JavaScript

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

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