event.stopPropagation()在使用jQuery 1.7的chrome中不起作用

出于某种原因,单击文档无法在Chrome中运行(未调用closeQuickView)。

元素是通过AJAX加载的,因此需要有.on()动作(以前的.live()现在已经在jQuery 1.7中弃用了)

使用此处给出的示例: 如何检测元素外部的单击? 作为基础

$('html').on('click', '.poster:not(.active) .image-effect', function (event) { var obj = $(this).parent(); // If there are no .close spans if (obj.find('.close').length === 0) { // Add the close element by javascript to remain semantic obj.find('.quick-view').append('×'); } // Close any open Quick Views closeQuickView(); // Add the active class (controls opacity) obj.addClass('active'); // Fade in the Quick View obj.find('.quick-view').fadeIn(200, 'easeInOutQuint'); event.preventDefault(); event.stopPropagation(); }); $('html').on('click', '.active', function () { return false; }); $('html').on('click', '.close', function () { closeQuickView(); }); $('html').on('click', '.quick-view', function (event) { event.stopPropagation(); }); // Close the QuickView with a button $('html').on('click', function () { closeQuickView(); }); function closeQuickView() { $('.poster').removeClass('active'); $('.quick-view').fadeOut(200, 'easeInOutQuint'); } 

我的标记如下:

 
Content

尝试event.stopImmediatePropagation

参考文档

jquery 1.6.4遭受同样的bug。 使用stopImmediatePropagation解决。