Hi Anyone know of a good function or class that can parse a string of HTML into the DOM? I'm trying to find an easy way to duplicate a complicated table row at the top of the table. I've managed to get it working by prepending table.innerHTML which is fine but it causes the browser to reload the entire table which messes with the scroll position and deletes some of the editable content in the table.
Any handy way to do this out there?
UPDATE:
Thanks guys, I'm not using jQuery for this project so I'd like to do it without it if possible. Here's an idea I found somewhere but I cant get it working (I need to replace the IDs of some of the elements so that's what cleanRowHTML function does with regex):
var newhtml = cleanRowHTML("<tr id='row"+lastID+"'>"+$('templateRow').innerHTML+"</tr>");
//$('aTable').innerHTML = $('aTable').innerHTML.replace("<!--[[:insert:]]-->","<!--[[:insert:]]-->"+newhtml);
var range = document.createRange();
range.selectNode($('templateRow'));
var parsedHTML = range.createContextualFragment(newhtml);
$('templateRow').appendChild(parsedHTML)