table,td点击事件冒泡。禁止ie,firefox中事件冒泡。

<script>
function bb(obj,evt)
{
alert('kk');
var e=(evt)?evt:window.event; //判断浏览器的类型,在基于ie内核的浏览器中的使用cancelBubble
if (window.event) {
e.cancelBubble=true;
} else {
//e.preventDefault(); //在基于firefox内核的浏览器中支持做法stopPropagation
e.stopPropagation();
}
}
</script>

<table onclick="alert('table');">
    <tr><td onclick="bb(this,event);">00000</td></tr>
</table>

猜你喜欢

转载自blog.csdn.net/wxljmy/article/details/21967111