JavaScript Change Text Colour onMouseOver



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




Try it! Put your mouse over this text


Script Source


<The following in the BODY section>

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


<The JavaScript >

<script type="text/javascript">

<!-- Hide

// by

function retOver(id)


var txt = document.getElementById(id); = '#3399ff';


function retOut(id)


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





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