Web Hosting Talk







View Full Version : Javascript to change text on an html page?


housefire
03-03-2008, 04:41 PM
Wondering if anyones got some simple code to update text on an html page after a javascript on click action?

ilyash
03-03-2008, 05:00 PM
Wondering if anyones got some simple code to update text on an html page after a javascript on click action?
Assuming your text is in a div or something.. give it an id
<div id="blah"> POOO </div>

After the action just do

document.getElementById("blah").innerHTML = "MEOW";

housefire
03-03-2008, 05:47 PM
And if I wanted to pull the value out of that text div to put into another field with js, any idea how id pull the value of it?

Codebird
03-03-2008, 07:03 PM
if you


<div id="blah"> POOO </div>
<div id="bloh"> MEOW </div>

document.getElementById("blah").innerHTML=
document.getElementById("bloh").innerHTML


this will put MEOW at the place of POOO