[js] Change text in a td or div (easily)? ::solved::

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

[js] Change text in a td or div (easily)? ::solved::

Post by Skara »

Same project as my other thread, but a different problem. I don't know where to start...

Ok, I have a bunch of rooms where you can mouse over things and go places. Anyway, I want to change the text of a td or div when you mouse over and off of certain images.
e.g.
You mouse over the lamp and the td's text changes to "Lamp." You mouse off and the td goes blank again.

The only way I know how to do this is to make a bunch of divs that appear and disappear. Problem with that is It'd take a whole lot more coding and a bunch of divs laying around.

I need something like this:
onmouseover="appear('string');"
...
<td name="infobox">[blank until mouseover]</td>
Last edited by Skara on Mon Sep 05, 2005 7:42 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

function appear(text) {
  document.getElementById('mbox').innerHTML = text;
}

function disappear() {
  document.getElementById('mbox').innerHTML = '';
}
------
<div id="mbox"></div>
------
<a href="#" onmouseover="appear('I\'m supa-coo!');" onmouseout="disappear();">blah</a>
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

haHA! Nifty. Thanks!
Post Reply