I have <div id="editform"></div>. I have certain html currently in it. How do I clear that html and insert completely different html in it?
I tried this but it did not work:
document.getElementById('editform').innerHTML = "";
document.getElementById('editform').innerHTML = "<input type=\"text\" placeholder=\"Title\" id=\"title\" name=\"title\" style=\"display:
block;\"><textarea rows=\"10\" style=\"display: block;\" id=\"textLoc\" placeholder=\"Text to test\"cols=\"50\"></textarea>";
Any ideas?
Your code works fine for me, as long as you remove (or escape) the line breaks from the new HTML string.
Example: http://jsbin.com/olabo4/
So change this:
to this:
or this: