Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript change html contents via javascript Re: change html contents via javascript

#92408
mik3ca
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>”.