日期:2014-05-16  浏览次数:20433 次

jqeury和DOM的this指针问题
jQuery.fn.newTarget = function() {  
return this.each(function() {
if (this.host != window.location.host) { $(this).attr('target', '_new'); } });};
请问各位大侠 为什么each前面用this而不用$(this) each不是jquery函数吗 按说应该用jqeury对象调用才对呀


------解决方案--------------------
each里的this,不是代表each,而是被循环的对象

each=for的循环

例如
$(json).each(function(){
...this
})
这里的this代表 的就是json