Handy document.createElement wrapper

April 1st, 2006

Looks like a very handy function that will ease the process of creating recursive multiple elements within JavaScript, have a look:
http://www.arantius.com/article/dollar-e

Example usage:

var element=$E({
    tag:'div',
    className:'toolGroup',
    id:'toolGroup_1',
    children:{
        tag:'div',
        className:'roundBarTop',
        children:[{
            tag:'div',
            className:'leftEdge'
        },{
            tag:'div',
            className:'rightEdge'
        },{
            tag:'div',
            className:'heading',
            children:[{
                tag:'a',
                className:'collapser'
            },
                'Group Heading'
            ]
        }]
    }
});

Example produces the following DOM fragment:

Very cool!

Web, JavaScript, Freebies, XMLHttp/Ajax | Comments | Trackback Jump to the top of this page

Comments are closed.

Just Organizing My Head

Meta