DOM templating with JavaScript?

I've been doing more and more JavaScript programming. I've run into a situation where I want to create a fragment then clone it repeatedly, changing a couple of ids and node values (picture a form with maybe ten fields, I want to update the value of a couple of fields and the id of a couple of fields and then add the result to the DOM).

It feels like overkill to walk the tree for each change. I kind of want to do a sprintf(). I am wondering if I can fetch the element by the technically duplicate id and change the node value and id to something else, before appending it to the tree with the original node (where the duplicate id could conflict).

Posted in Programming

202: Accepted Archives

Feed icon We use Feedburner to distribute our web feeds: 202 Accepted Feed

feedburner graphic
Google

Copyright 2002–2011 Artific Consulting LLC.

Unless otherwise noted, content is licensed for reuse under the Creative Commons Attribution-ShareAlike 3.0 License. Please read and understand the license before repurposing content from this site.