首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jqeury和DOM的this指针有关问题

2012-04-03 
jqeury和DOM的this指针问题jQuery.fn.newTarget function() {return this.each(function() {if (this.ho

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

热点排行