Laisser un commentaire
You must know the $ Function in prototype (also in jQuery and mootools) that helps you target elements in Javascript. Well, here's my take on it.
Here's the code :
-
function $( magic , node ){
-
//model : [@][id][:][tag] -
-
var keys = /^([\@]*)([\w+]*)([\:]*)([\w+]*)$/(magic);
-
var isArray = keys[1];
-
var id = keys[2];
-
var tag = keys[4];
-
-
if( tag == "" ){tag = "*"}
-
if( node == undefined ){ node = document }
-
-
var nodes = node.getElementsByTagName(tag);
-
var ret = new Array;
-
for( var i=0; i < nodes.length; i++ ){
