Using innerHTML (like $('<div></div>') is faster than DOM creation methods;
see http://www.quirksmode.org/dom/innerhtml.html
but for complicated trees it's harder to understand and debug.


nrwsteff wrote:
> 
> short question:
> 
> what is the recommanded/better/fastest (memory footprint/execution time)
> jQuery way to create dynamic content?
> the length of code is not so important for me. 
> or should i use one of the DOM creation plugins?
> 
> a)
> var myIdVar = 'id1';
> var myClassVar = 'class1';
> $('<div></div>').attr({'id':myIdVar,'class':myClassVar}).appendTo('#myAnchor
> ');
> 
> or 
> 
> b)
> var myIdVar = 'id1';
> var myClassVar = 'class1';
> var myHtml = '<div ';
> myHtml += 'id="'+myIdVar+'" class="'+myClassVar+'"></div>';
> $('#myAnchor').append(myHtml);
> 
> regards steff
> 
> 
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Q%3A-best-way-to-create-dynamic-content--tf3304274.html#a9196649
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to