Changing Text InnerHTML
Every HTML element has an InnerHtml attribute that defines the HTML code and text that occurs between the element's opening and closing tags. By changing an element's innerHTML after some user interaction, you can make your web page more interactive.
However, using innerHTML requires some preparation if you want to be able to take advantage of it easily and reliably. First, you must give the ID card that you want to change. With the identifier in place, you will be able to use the getElementById function, which works in all browsers.
After you think about establishing the elements you can now manipulate the text. To get started, let's try changing the text to a bold marker.
Let’s take a look at how to use js innerHTML to change the div value.
<script type="text/javascript"> function changeText(){ document.getElementById('boldStuff').innerHTML = 'Fred Flinstone'; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type='button' onclick='changeText()' value='Change Text'/>
For more js innerHTML methods to change div content, please pay attention to the PHP Chinese website for related articles!