/ Published in: JavaScript
This is a very basic wrapper for querySelectorAll. Just add prototypes and whatever else you need.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var $ = function(selector, node) { // Bare-Bones Selector Engine var selector, node; selector = selector.trim(); node = node || document.body; if (selector != null) { return Array.prototype.slice.call(node.querySelectorAll(selector), 0); } } Array.prototype.put = function(html) { for (var i = 0; i < this.length; i++) { this[i].innerHTML = html; } return this; } $('div').put('yay!');