js阻止事件冒泡的方法

/********************************************js方法***************************************************/

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

/********************************************事件调用***********************************************/

<div onclick="doSomething(this,event);">00000000000000000</div>

原文地址:https://www.cnblogs.com/mingjian/p/4311291.html