相关疑难解决方法(0)

jquery.each() - "this"vs valueOfElement

jQuery.each()循环中,我一直认为这this相当于valueOfElement.有人可以解释这个区别吗?

例:

$.each(object, function(i, val){
    $('body').append('<b>valueOfElement:</b> ' + typeof val + ' - ' +  
    '<b>this: </b>' + typeof this + '<br/>');
});
Run Code Online (Sandbox Code Playgroud)

结果:

valueOfElement: string - this: object
valueOfElement: boolean - this: object
valueOfElement: object - this: object
Run Code Online (Sandbox Code Playgroud)

小提琴

javascript jquery

7
推荐指数
1
解决办法
764
查看次数

标签 统计

javascript ×1

jquery ×1