Click to See Complete Forum and Search --> : I'm new to this,bare with me-Q's about document.writing text


togetslim
03-19-2003, 07:46 AM
Is there a way to write text to a page with a javascript, then after the page has loaded, by clicking onto a button, clear the origonal text and place a new line of text in its spot without it jumping to a new page to write the text? Like how the image-flips switch with an onMouseOver and onMouseOut. Can you get text to do the same sort of effect? Maybe I'm just writing it wrong. Any suggestions would help.
Thanks
AM

pyro
03-19-2003, 07:51 AM
Yes, you use document.getElementById, something like this:

<html>
<head>
<script language="javascript" type="text/javascript">
function swapText()
{
document.getElementById("mydiv").innerHTML = "New Text";
}
</script>
</head>
<body>
<div id="mydiv">Original text</div>
<a href="#" onClick="swapText(); return false;">change text</a>
</body>
</html>