JavaScript Change Text Colour onMouseOver

 

 

This script will allow you to change the text colour onMouseOver using JavaScript.

 

 

Example

Try it! Put your mouse over this text

 

Script Source

 

<The following in the BODY section>

<span id="myP" onMouseOut="retOut(this.id);" onMouseOver="retOver(this.id);">Try it! Put your mouse over this text </span>

 

<The JavaScript >

<script type="text/javascript">

<!-- Hide

// by www.wizzardweb.co.uk

function retOver(id)

{

var txt = document.getElementById(id);

txt.style.backgroundColor = '#3399ff';

}

function retOut(id)

{

document.getElementById(id).style.backgroundColor = '#ffffff';

}

//-->

</script>

 

Please let me know if this script was helpful to you.

[rating]