Home › Forums › JavaScript › change html contents via javascript › Re: change html contents via javascript
December 10, 2011 at 2:55 pm
#92408
Member
easiest way out for todays browsers is to label the element of the section that is supposed to change. Here’s an example of what I mean…
<div ID=”ABC”>change me</div>
So above, we want to change the text “change me”.
then in javascript, use commands like this:
var mystuff=getElementById(“ABC”);
mystuff.innerHTML=”<h2>changed</h2>”;
The first command (I may have missed an S or messed up on capitalization) will create a variable to hold an internal value which is the same as the DIV above.
The second command modifies the html data between “<div ID=”ABC”>” and “</div>”.