var MyAPI = {
css: function(key, val){
if (val === undefined)
return this[0].style[key];
for (var i = 0; i < this.length; i++) {
this[i].style[key] = val;
}
return this;
},
hide: function() {
return this.css("display", "none");
},
show: function() {
if (this.css("display") == "none")
return this.css("display", "block");
return this.css("display", "");
}
}
function _el(selector) {
var collection = document.querySelectorAll(selector),
wrapped = [].slice.call(collection);
for (var method in MyAPI) {
wrapped[method] = MyAPI[method];
}
return wrapped;
}
_el("#mydiv").css("border", "1px solid black");