Thomas Horster

eat the cookie before the cookie eats you

JavaScript Miniframework

| Keine Kommentare

//implement missing function
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp(‘\\b’+cl+’\\b’);
var elem = this.getElementsByTagName(‘*’);
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
return retnode;

//framework functions
function $(id){ return document.getElementById(id); }
function html(id, html){ $(id).innerHTML = html; }
function css(id, style){ $(id).style.cssText += ‘;’+style;}
function $$(class){ return document.getElementsByClassName(class); }

You can find a testrun here:

Based on a Thomas Fuchs article found here.

Autor: Tom

I am Jack's evil father!

Hinterlasse eine Antwort

Pflichtfelder sind mit * markiert.