PDA

View Full Version : Change Text onMouseOver


surferdave
09-03-2002, 10:06 PM
Hello

I would like to create a function that will change the text (a message) in a cell of a table when user mouse over different links.

For example, when user mouse over the link CONTACT US, the text in the cell would be the address and if the user mouse over the link MISSION STATEMENT the text in the cell would change to the mission statment of the company.

I know how to do this effect with image files. On mouse over the image would change. This is how I did it below

function new()
{
document.tablecell.src="newpic.jpg"
}
function old()
{
document.tablecell.src="oldpic().jpg"
}

<td onMouseOver="new()" onMouseOut="old()">CLICK HERE</td>

Can someone tell me how to create this effect with Text?

Thank You

Dave

caldasgsm
09-03-2002, 10:52 PM
with a TD you just have to use the innerHTML property or the innerText.

document.tablecell.innerHTML = '<b>hello world</b>'

beware that the innerHTML properties is more 'heavy' to the browser, because he as to parse the string for HTML tags..

if you can or you want to use only text is better and in that case use the innerText property

surferdave
09-03-2002, 11:02 PM
thanks that seem to work great!!