jQuery对象本质上是一种类数组对象
var $$ = function (nodeList) {
return new $$.fn.init(nodeList);
};
$$.fn= $$.prototype = {
toString:function () {
return this.slice();
},
constructor: $$,
init:function ( arr ) { // 创建类数组对象 for (var i = 0, l = arr.length; i
使用示例:var para = $$( document.getElementsByTagName('p') );
para.each(function(){
this.className += " " + 'goodbye';
});
Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号