我想知道append()里的参数是函数,需要括号吗?例子里加不加括号结果都一样,标准的是啥
3 回答
我认为不加括号:
框架中是这样的
append: function() {
return this.domManip( arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.appendChild( elem );
}
});
},
在domManip 中
domManip: function( args, callback ){
value = args[0],
isFunction = jQuery.isFunction( value );
}
通过isFunction最终定位到
type: function( obj ) {
if ( obj == null ) {
return obj + "";
}
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call(obj) ] || "object" :
typeof obj;
},
跟踪class2type 最终发现 只需要function 的nama 即函数名
举报