nrwsteff schrieb:
> 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);
I wrote a yet unreleas plugin that extends jQuery's html() and text() 
methods, allowing you to do something like this:

$("#myanchor").html("<div id='%' class='%'>%</div>", myIdVar, myClassVar, 
myContent);

That would produce:

<div id='id1' class='class1'>some content</div>

 The same is possible with text().

Would that work for you? If so, I'd try to release that plugin.

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to