How to stop event propagation with inline onclick attribute?

前端 未结 13 2083
情书的邮戳
情书的邮戳 2020-11-21 23:46

Consider the following:

13条回答
  •  温柔的废话
    2020-11-22 00:46

    Use this function, it will test for the existence of the correct method.

    function disabledEventPropagation(event)
    {
       if (event.stopPropagation){
           event.stopPropagation();
       }
       else if(window.event){
          window.event.cancelBubble=true;
       }
    }
    

提交回复
热议问题