Too much recursion 

Higher Order Javascript


   Subscribe in NewsGator Online    Subscribe in Rojo    Add to Google      Add to My AOL   Subscribe in FeedLounge   Add to netvibes  

Brendan Eich's Roadmap  Standard ECMA-262  Yahoo! UI Library     

Sunday, August 06, 2006


DOM Node Creation Helpers

These are the foundation of this.js(another a.p.i!), available for download.
// DOM Node Creation Helpers R.E.M. Aug.2006
// Generic Get Element, $, getEl()
// Args:[id],[element],[array]of.. Returns: [element] or [array] of elements
var $ = function getEl(e) {
if (typeof e == 'string') {return window.document.getElementById(e);}
if (e[0]) {var i=e.length; while(i--){e[i]=arguments.callee(e[i]);}return e;}
return e; //element
// Generic Append Element(),$A, appendElement()
// Appends [element] to [element] or [Array] of elements
var appendElement = $A =function(bag, marbles) {
if (marbles.constructor == Array){var l=marbles.length,i;
for(i=0;i else {bag.appendChild(marbles);} return bag;
// Generic Create Element, $X, exNihilo()
// Creates element and/or adds attributes to node and/or adds styles to node
var exNihilo = $X =function (el,attributes,styles) {
if (el==='textnode')
{ return document.createTextNode(((attributes)? attributes:' ')); }
var node=(el.constructor==String)?document.createElement(el): el,arg;
if (attributes){for (arg in attributes){node[arg]=attributes[arg];} }
if (styles) {for (arg in styles) {[arg]= styles[arg];} }
return node;

Comments: Post a Comment

Links to this post:

Create a Link

<< Home


June 2006   July 2006   August 2006   September 2006  

This page is powered by Blogger. Isn't yours?