Code for preventing the parent element to stop firing an event when child is invoked?

Kmandapalli
Posted by Kmandapalli under jQuery category on | Points: 40 | Views : 1501
$('#' + id + ' .divlink1').bind('click', function (e) {
alert('div clicked');
});

$('#' + id + ' .divlink1 a').bind('click', function (e) {
e.preventDefault();
alert('link clicked');
});

$('#' + id + ' .divlink2').bind('click', function (e) {
alert('div clicked');
});

$('#' + id + ' .divlink2 a').bind('click', function (e) {
e.preventDefault();
e.stopPropagation();
alert('link clicked');
});

Comments or Responses

Login to post response