Jump to content

Menu Changecolor


newbman

Recommended Posts

I'm trying to make a dynamic menu. When the cursor goes over the <td>, the background color is suppose to change slightly every 10 miliseconds, but there is an error when I try it. Here's the code:

<head><style type="text/css">td.mainlinks{	background-color:#0099ff;	width: 20%;	text-align: center;	cursor: pointer;}table{	position:relative;	width:100%;}span.main{	font-size:18px;	font-family:garamond;	color: #000000;	font-weight:bold;	letter-spacing:2px;}</style><script type="text/javascript">i=1function color(){for (i=1;i<=10;i++){var t=setTimeout("i=i",10)document.getElementById("mytd").style.bgColor="rgb(0,153-10*i,255-10*i)"}}</script></head><body><table border="0">	<td class="mainlinks" id="mytd" onClick='window.location="home.html"'         onMouseover="color()"><span class="main">Home</span></td></table></div></body>

Nothing happens

Link to comment
Share on other sites

Not really sure what you're looking for with that. Something like:

<head><style type="text/css">td.mainlinks { background-color:#0099ff; width: 20%; text-align: center; cursor: pointer;}table { position:relative; width:100%;}span.main { font-size:18px; font-family:garamond; color: #000000; font-weight:bold; letter-spacing:2px;}</style><script type="text/javascript">var num = 1;var tmrColorfunction iDoColor(){	var clrs = "0," + (153 - (10 * num) ) + "," + (255-(10*num)) + "";	document.getElementById("mytd").style.backgroundColor = "rgb(" + clrs + ")"	num++;}function iColor(switcher){	if(switcher == 0){  window.clearInterval(tmrColor);    num = 1;  var clrs = "0," + (153 - (10 * num) ) + "," + (255-(10*num)) + "";  document.getElementById("mytd").style.backgroundColor = "rgb(" + clrs + ")"	} else {  tmrColor = setInterval( "iDoColor()" , 100)	}}</script></head><body><table border="0"><tr><td class="mainlinks" id="mytd" onClick='window.location="home.html"' onMouseover="iColor(1)" onMouseOut="iColor(0)"><span class="main">Home</span></td></tr></table>

??

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...