jquery1.0里执行 $('#aa').mouseover(fun) this指向的改变


这是源码11531169行的 原型上的mouseover方法
```javascript

new function(){

    var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
        "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," + 
        "submit,keydown,keypress,keyup,error").split(",");

    // Go through all the event names, but make sure that
    // it is enclosed properly
    for ( var i = 0; i < e.length; i++ ) new function(){
            
        var o = e[i];
        
        // Handle event binding
        jQuery.fn[o] = function(f){
            console.log(this,"1167原型上的this");  //这里的this还是jQuery对象{0div#aa,length1}
            return f ? this.bind(o, f) : this.trigger(o);//当进入bind方法时 this指向发生了改变
        };


这是1051到1056行 jQuery原型上的bind方法

    bind: function( type, fn ) {
            console.log("1052bind",this)   //这里的this变成了<div id="aa"></div>成了dom元素
            if ( fn.constructor == String )
                fn = new Function("e", ( !fn.indexOf(".") ? "$(this)" : "return " ) + fn);
            jQuery.event.add( this, type, fn );
        },

bind方法时this.bind来调佣的调佣前this是jQuery对象,为什么调佣后变成了dom对象

源码中310到315行 \


jQuery.each( jQuery.macros.each, function(i,n){
            jQuery.fn[ i ] = function() {
                console.log(this,i,"11111213")
                return this.each( n, arguments );
            };
        });

this是在这里发生的改变 这里的i就是bind名 n对应的就是function(){} bind方法体也就是在进入bind方法体之前它已经遍历了一次this 提取dom元素