Is there a good JS function or class that can seamlessly parse a string of HTML into the DOM without resetting existing content? I'm trying to find an easy way to duplicate a complicated table row at the top of the table.
It obviously will work like this:
element.innerHTML = newHTML + element.innerHTML;
However, this causes the browser to reload the entire table which resets the scroll position and deletes any unsaved editable content in the table.
UPDATE:
I'm not using jQuery for this project. Here's an idea I found somewhere but I cant get it working:
var templateRow = document.getElementById( 'templateRow' );
var newhtml = "<tr id='row"+lastID+"'>"+'templateRow'.innerHTML+"</tr>";
var range = document.createRange();
range.selectNode( 'templateRow' );
var parsedHTML = range.createContextualFragment( newhtml );
templateRow.appendChild( parsedHTML )