标签:
jquery的event.stoppropagation()是兼容firefox、chrome的,但不兼容ie
兼容写法:
if (event.stopPropagation) { event.stopPropagation(); } else if (window.event) { window.event.cancelBubble = true; }
window.event在ie和chrome上是有的,firefox上没有window.event,需要函数中参数带入
$(".dom").click(function (event) { if (event.stopPropagation) { event.stopPropagation(); } else if (window.event) { window.event.cancelBubble = true; } ... });
标签:
原文地址:http://www.cnblogs.com/hpyou/p/5504875.html