35行的山寨版jQuery-创新互联
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';
});
分享文章:35行的山寨版jQuery-创新互联
标题URL:http://scyanting.com/article/jdcdi.html