Jquery stopPropagation method dosen\'t work with live method. Below the code is works fine with click instead of live method. Any help greatly appreciated.
I had no problems using pure javascript for the same. Though this doesn't relate to OP's question(looks complicated) just posting this answer for others who prefers JS over jQuery
HTML:
-
-
jQuery:
$(".ac_results li").live('click', function() {
alert('li called')
});
$(".ac_results li input[type='checkbox']").live('click', function(e) {
e.stopPropagation(); //does not work
alert('check box called');
});
Javascript:
//get child elements
var checkbox = document.getElementsByTagName('input');
for(var i=0;i
var checkbox = document.getElementsByTagName('input');
for (var i = 0; i < checkbox.length; i++) {
checkbox[i].onclick = callCheck;
}
var li = document.getElementsByTagName('li');
for (var j = 0; j < li.length; j++) {
li[j].onclick = liClick;
}
function liClick(e) {
alert('list item clicked');
}
function callCheck(e) {
e.stopPropagation();
alert('checkbox clicked');
}
-
-