这是一种编程技巧也是一种策略,填写这些目的使jquery内部对元素的引用是唯一的,这样做的目的是:个人猜测是为了缓存节点,对每个节点进行区分,缓存的目的就是使内部读取元素速度更快。
可以看这个详细探讨,由于某部分原因需要特殊方式才能打开这个网页。
https://groups.google.com/forum/#!topic/jquery-en/I4Kmahzp7fY
为了方便阅读,我复制过来了。// it's meant for internal use only. The jQuery core file uses it to calculate nth-child. Here is the source (with my emphasis):CHILD: function(elem, match){// ...
case 'nth':
var first = match[2], last = match[3]; if ( first == 1 && last == 0 ) {
return true;
}
var doneName = match[0],
parent = elem.parentNode; if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
node.nodeIndex = ++count;
}
}
parent.sizcache = doneName;
}
var diff = elem.nodeIndex - last;
if ( first == 0 ) {
return diff == 0;
} else {
return ( diff % first == 0 && diff / first >= 0 );
}
}// ...
},
可以看这个详细探讨,由于某部分原因需要特殊方式才能打开这个网页。
https://groups.google.com/forum/#!topic/jquery-en/I4Kmahzp7fY
为了方便阅读,我复制过来了。// it's meant for internal use only. The jQuery core file uses it to calculate nth-child. Here is the source (with my emphasis):CHILD: function(elem, match){// ...
case 'nth':
var first = match[2], last = match[3]; if ( first == 1 && last == 0 ) {
return true;
}
var doneName = match[0],
parent = elem.parentNode; if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
node.nodeIndex = ++count;
}
}
parent.sizcache = doneName;
}
var diff = elem.nodeIndex - last;
if ( first == 0 ) {
return diff == 0;
} else {
return ( diff % first == 0 && diff / first >= 0 );
}
}// ...
},
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货