Javascript examples for DOM:Document getElementById
Use document.getElementById().innerHTML to rewrite the original html
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www . j ava2s .c om var myElement = document.getElementById('test'); var originalText = myElement.innerHTML.toString(); myElement.innerHTML = originalText+" new text"; } </script> </head> <body> <div id="test"> original text </div> </body> </html>