All code
(function () {
function _$ (ELS) {
This.element = [];
for (var i = 0, len = els.length; i < Len; i++) {
var element = Els[i],
Typeclass = Element.indexof ("."),
TypeId = Element.indexof ("#");
if (typeof element = = = ' String ') {
if (TypeId ==0) {
element = document.getElementById (element);
}
if (Typeclass = = 0) {
element = Document.getelementsbyclassname (element);
}
}
This.element.push (Element);
}
return this;
}
_$.prototype = {
Each:function (FN) {
for (var i = 0, len = this.element.length; i < Len; i++) {
Fn.call (this, this.element[i]);
}
return this;
},
Setstyle:function (prop, Val) {
This.each (function (EL) {
El.style[prop] = val;
});
return this;
},
Show:function () {
var = this;
This.each (function (EL) {
That.setstyle (' Display ', ' none ');
});
return this;
},
Addevent:function (Type, fn) {
var add = function (EL) {
if (Window.addeventlistener) {
El.addeventlistener (Type, FN, false);
}else if (window.attachevent) {
El.attachevent (' on ' + type, fn);
}
};
This.each (function (EL) {
Add (EL);
});
}
};
window.$ = function () {
return new _$ (arguments);
}
})();
A simple implementation of the jquery $ selection symbol