BreefsNeuri
New Member
SIMPLIFIED EXAMPLE CODE:\[code\]var $ = function(selector, node) { // Selector engine var selector = selector.trim(), node = node || document.body; if (selector != null) { return Array.prototype.slice.call(node.querySelectorAll(selector), 0); } }}\[/code\]I want to use it like this...:\[code\]$("div").innerHTML='It works!';\[/code\]...not like this...:\[code\]$("div")[0].innerHTML='It works only on the specified index!';\[/code\]...or this...:\[code\]for(i=0;i<$('div');i++) { $("div").innerHTML='It works great but it's ugly!';}\[/code\]...and definitely not this because I would like it to be compatible with native methods:\[code\]if(!Array.prototype.innerHTML) { Array.prototype.innerHTML = function(html) { for (var i = 0; i < this.length; i++) { this.innerHTML = html; } }}$("div").innerHTML('It works by looping the method, and ruins method chaining!');\[/code\]I decided to build this engine to better learn JavaScript; It's working but I am hoping I can learn some more from the kind members of Stack Overflow. Any help would be much appreciated!