2011-08-04 35 views

回答

6

i.each环路的当前迭代元素的索引。 e是实际的DOM元素。

var $e = $(e); 

分配$e变量包装在jQuery对象,以便采取的jQuery的归一化的DOM方法利用当前DOM元素。

插件典型地获得适用于特定选择匹配,所以所有元素:

$("div").rssfeed(url, options, fn); 

将导致插件遍历.each环路中的所有div元素。

+2

附加信息:这是降低处理成本的好方法,而不是在需要时再次安装对象。 – Jules

+0

对不起还是有点不清楚。现在是'$ e'引用一个DOM元素? – locoboy

+0

不,$ e被分配了将'e'封装在jQuery对象中的结果。 'e'只是一个普通的DOM元素。 – karim79

1
$.fn.rssfeed = function (url, options, fn) { 

    //Here this refers to the jquery object 
    //i refers to the index in the loop 
    //e refers to the dom element os $(e) will give the jquery object corresponding to the dom element 
    return this.each(function (i, e) { 
      var $e = $(e); 
      var s = ''; 
} 
0

每个(函数(I,E))就像

for(var i = 0; i < this.length; i++){ 
    var $e = $(this[i]); 
} 

事实上,E也许DOM元素和$(e)是只是用户的jQuery,使其成为一个对象($é );

相关问题