On Dec 6, 2010, at 11:48 AM, Luke wrote:


I'm loading some plain HTML via Ajax.Request and insert it in a DIV. I
need to perform some extensions on the HTML I load though, which
brought me to the idea to create DOM from the loaded markup, extend it
and insert it.

So my question is: Is there a convenient way to create DOM from a
string of HTML-markup? The only way I found, or have been told, is to
create a DIV with new Element, insert the markup in it, and remove the
DIV again. But I find that kinda hacky. Isn't there a good way for

It's OT for this list, but have a look at Prototype.js. You can create a new DOM element in memory, and do all the things you want to it without ever showing it to the user.

var foo = new Element('div', {}).update(my_html).do_stuff_here().innerHTML;


You received this message because you are subscribed to the Google Groups "Prototype 
& script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to