> Here is my little plugin to create dom element: > > http://204.13.69.149/~wang/ > > My questions are: > 1, Has anybody done this before? > 2, As it's my first crack on jQuery, anything wrong with the api call? > 3, Is there any more elegant solutions?
As Klaus said, the name is a bit off but I do think this approach has some promise. Right now I am using Mike Geary's DOM creation functions. http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype I like them because (unlike string building and innerHTML) there are no gotchas with the contents of the strings you put into the DOM functions. However, the $.DIV syntax is not pretty. More important, doing things in the "natural" way involves attaching event handlers before the element is added to the document tree, which causes a small memory leak in IE6. Since dom() changes the selected nodes, jQuery convention says it should use pushStack to save the previous set of nodes. Building a DOM tree often several levels, though, so a pushStack on every element could result in a lot of pushed state that you don't care about. Let's say I want to create a list like "<ul><li>one</li><li>two</li></ul>". How would I do that with tag()? I can only pass in one tag, and it's always appended as a child. _______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
