innerHTML store as copy, not reference?
Posted: Mon Aug 07, 2006 11:00 am
Take the code:
I'm trying to store an element's HTML in a variable, change it temporarily and then restore it again. The HTML seems to be stored by reference though, and so when I change it's value the value of oldHTML changes. Clues or workarounds? 
Code: Select all
<script type="text/javascript">
<!-- Hide me from the peeking people
var oldHTML;
function showNewHTML(el)
{
//I think this is where it breaks
oldHTML = el.innerHTML;
el.innerHTML = 'New text';
}
function restoreOldHTML(el)
{
el.innerHTML = oldHTML; //oldHTML seems to now be 'New text'
}
// -->
</script>