1. 如何阻止事件冒泡
//非IE
if (event && event.stopPropagation)
event.stopPropagation();
else//IE
window.event.cancelBubble = true;
2.获取控件ID
if (document.all) {
//IE
alert(event.srcElement.tagName+":"+event.srcElement.id);
}
else {
//Firefox
alert(event.target.tagName + ":" + event.target.id);
}
代码如下:
//非IE
if (event && event.stopPropagation)
event.stopPropagation();
else//IE
window.event.cancelBubble = true;
2.获取控件ID
代码如下:
if (document.all) {
//IE
alert(event.srcElement.tagName+":"+event.srcElement.id);
}
else {
//Firefox
alert(event.target.tagName + ":" + event.target.id);
}