我正在尝试设置一个在单击没有.four类的任何内容时触发的事件。但是,.four即使我使用的是e.stopPropagation().
$("html").one("click", ":not(.four)", function(e){
e.stopPropagation();
console.log("Something without class 'four' was clicked that had class: " + $(e.srcElement).attr("class") );
});
( jsFiddle 演示)
这也不起作用:
$("html").not('.four').on("click", function(e){
两个输出:Something without class 'four' was clicked that had class: four
我遇到了很多麻烦,:not()我怀疑很多可能与我:not()现在支持 CSS3 的浏览器有关,但我仍然无法理解这个简单的问题。