HTML:
<a href='http://www.jsfiddle.net'><span>link</span></a>
Script:
$('span').click(function(event) {
window.open('http://www.google.com');
event.stopImmediatePropagation();
//The line below does prevent jsfiddle.net from loading on the right.
//event.preventDefault();
});
$('a').click(function() {
//This function is not triggered as event propagation has been stopped.
alert('You will never see this.');
});
Clicking on "link" in the demo will cause both google.com and jsfiddle.net to be opened. Here comes my question: Why is the default behavior of <a>
(opening jsfiddle.net in this case) inherited by its children (<span>
in this case)? Are there any specifications I can refer to?
Thanks in advance.