Biwood
2014-07-17 21:42:04 +08:00
直接看了一下未编译版的jQuery源码,这里是click()的定义:
click: {
// For checkbox, fire native event so checked state will be right
trigger: function() {
if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
this.click();
return false;
}
},
// For cross-browser consistency, don't fire native .click() on links
_default: function( event ) {
return jQuery.nodeName( event.target, "a" );
}
}
注释里面有一句“For cross-browser consistency, don't fire native .click() on links”,大意是“为了兼容多个浏览器,不触发链接上原生的click()事件”。这应该是jQuery为了增强其兼容性而做出的妥协吧。