Given this div on an html page :
<div id="div1"> <table> fred </div>
How can I use javascript to extract the contents of "div1" into a string, so that the string has this value :
" <table> fred "
Using code such as :
var a = document.getElementById('div1').innerHTML;
is unsuccessful, because the browser adds markup to the string to try to create valid html table markup.