Hi, > This looks really interesting: > http://www.zachleat.com/web/2007/07/07/domdom-easy-dom-element-creation/ > > Of course his proposal for porting doesn't quite work out with jQuery, > but a port that is integrated into jQuery's API would be really cool.
A nice Idea, but somehow I feel uncomfortable with it. I've been using Oslows DOM builder which uses arrays and objects to express the desired DOM up to now and somehow I prefere it, because it doesn't need to parse any strings before it starts building Objects. Actually a mixture of both would be cool: $.dom([ 'a', {href:'asdf'}, ['asdfasdf'] ]); creates like Oslows code <a href="asdf">asdfasdf</a> while $.dom([ 'a#jkl[href=asdf]', ['asdfasdf'] ]); creates <a id="jkl" href="asdf">asdfasdf</a> and $.dom([ 'div.test > a#jkl[href=asdf] + a[href=asdf], p', [ 'span.lkj', ['asdfasdf'] ] ]); creates <div class="test"> <a id="jkl" href="asdf"><span class="lkj">asdfasdf</span></a> <a href="asdf"><span class="lkj">asdfasdf</span></a> </div> <p><span class="lkj">asdfasdf</span></p> Of course $.dom() always should return jQuery Objects. What do you think? I think it will be a really efficient way to create even a rather complex DOM tree. $.dom([ 'table[width="100%"][border="2"][cellpadding="0"] > tr + tr +tr +tr', [ 'td[style="background-color:red"],td', ['asdfasdf'] ] ]); <table width="100%" border="2" cellpadding="0"> <tr><td style="background-color:red">asdfasdf</td><td>asdfasdf</td></tr> <tr><td style="background-color:red">asdfasdf</td><td>asdfasdf</td></tr> <tr><td style="background-color:red">asdfasdf</td><td>asdfasdf</td></tr> <tr><td style="background-color:red">asdfasdf</td><td>asdfasdf</td></tr> </table> Christof