Making Javascript DOM a Piece of Cake with the graft() Function
In an earlier article I presented DOM as a useful way to construct documents on the fly in Javascript. DOM is well known for this purpose, but it’s also well known for being extremely irritating and verbose to use in Javascript. Some programmers may be tempted to use quoted HTML combined with the innerHTML property, which may (for them) be somewhat easier to crank out than DOM code. But this is hardly a way to go forward, and creates all sorts of problems when using AJAX, JSON, or when working in an environment involving a lot of strict XML usage. Casting all of that aside, this article will demonstrate the use of the graft() function to simplify the construction of DOM structures using Javascript’s own simple object notation.
More after the jump..
