在table中的tr上加了click事件,td中也有按钮或者onclick事件的时候,点击按钮会触发多个事件。
问题解决:
在需要阻止上个事件触发的function中执行该方法。js中需要加入放冒泡事件
例如:执行按钮,触发了tr
function stopPropagation(e) {
e = e || window.event;
if(e.stopPropagation) { //W3C阻止冒泡方法
e.stopPropagation();
} else {
e.cancelBubble = true; //IE阻止冒泡方法
}
}
function deleTelConfirm(idstr,telNumber,url,event){
event.stopPropagation();
alert(1);
}
html调用:
deleTelConfirm('','','',event);