ChimpyLoLo
asked on
onMouseover=(CSS Class)?
any possibility of making a Mouseover within a <TD> tag styled by a CSS class?
i.e., <TD class="styleA" onMouseover="blah='styleB' " onMouseout="blah='styleA'" >BLAH</TD>
Any help will be hugely appreciated... Thanks, TW
i.e., <TD class="styleA" onMouseover="blah='styleB'
Any help will be hugely appreciated... Thanks, TW
yes it can be done, though not quite like that... as for why noone has answered you, this isn't a paid-tech support service... we 'experts' are people who donate our time and effort to helping others... so there isn;t always someone immediately around... that and we don;t get notified when a question comes in, so some time might go by...
here is what you do (if I am understanding your question correctly)
in your css, you do the following:
a.linkstyle { /*link style goes here*/}
a.linkstyle:hover { /*mouseover style goes here*/}
here is what you do (if I am understanding your question correctly)
in your css, you do the following:
a.linkstyle { /*link style goes here*/}
a.linkstyle:hover { /*mouseover style goes here*/}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can do something like this. I got this code off the internet sometime ago.
<html>
<style type="text/css"> td.onmouse { background-color: #000000; color: #FFFFFF; } td.offmouse { background-color: #FFFFFF; color: #000000; } </style>
</style>
<body>
<table>
<td class="menuoff" onmouseover="className='on mouse';" onmouseout="className='off mouse';">T ext that will be changed</td>
</table>
</body>
</html>
<html>
<style type="text/css"> td.onmouse { background-color: #000000; color: #FFFFFF; } td.offmouse { background-color: #FFFFFF; color: #000000; } </style>
</style>
<body>
<table>
<td class="menuoff" onmouseover="className='on
</table>
</body>
</html>
Try this:
<html>
<head>
<title>Changing cell onmouseover</title>
<style>
<!--
td {background-color:limegree n;cursor:d efault;bor der:1pt orange solid;}
.green {background-color:green;co lor:yellow ;}
.limegreen {background-color:limegree n;color:te al;}
.red {background-color:red;colo r:yellow;}
.pink {background-color:pink;col or:teal;}
-->
</style>
</head><body>
A colorful example of onmouseover effect, javascript and css: (hover mouse on cell)
<table style="border:1pt blue solid;background-color:lig htblue;">
<tr><td class="limegreen"
onMouseover="this.classNam e='green'; "
onMouseout="this.className ='limegree n';">
this is a cell
</td></tr><tr>
<td class="limegreen"
onMouseover="this.classNam e='red';"
onMouseout="this.className ='limegree n';">
this is a cell
</td></tr>
</table>
</body>
</html>
<html>
<head>
<title>Changing cell onmouseover</title>
<style>
<!--
td {background-color:limegree
.green {background-color:green;co
.limegreen {background-color:limegree
.red {background-color:red;colo
.pink {background-color:pink;col
-->
</style>
</head><body>
A colorful example of onmouseover effect, javascript and css: (hover mouse on cell)
<table style="border:1pt blue solid;background-color:lig
<tr><td class="limegreen"
onMouseover="this.classNam
onMouseout="this.className
this is a cell
</td></tr><tr>
<td class="limegreen"
onMouseover="this.classNam
onMouseout="this.className
this is a cell
</td></tr>
</table>
</body>
</html>
Just noticed my comment is an expansion on dorwards answer.. I just added more style for the example.
dorward has provided you with the correct answer here, is there a reason you haven't closed out this question yet?
this works plenty well in mozilla and the likes:
<html>
<head>
<title>hover selector</title>
<style type="text/css">
box {
padding: 3em;
margin: 1em;
border: 4px solid #000;
background: #ff0;
color: #060;
}
box:hover {
border: 4px dashed #060;
background: #000;
color: #f0f;
}
</style>
</head>
<body>
<div id="box"> blah blah blah </div>
</body>
</html>
<html>
<head>
<title>hover selector</title>
<style type="text/css">
box {
padding: 3em;
margin: 1em;
border: 4px solid #000;
background: #ff0;
color: #060;
}
box:hover {
border: 4px dashed #060;
background: #000;
color: #f0f;
}
</style>
</head>
<body>
<div id="box"> blah blah blah </div>
</body>
</html>
#box and #box:hover, oops
yes it is possible, and very simple
create a file called root.js and put this code in it:
function MouseEffect( event )
{ switch( event.type )
{ case "mouseover":
if( document.all )
{ window.event.srcElement.st yle.backgr oundColor = '#840029';
window.event.srcElement.st yle.color = '#ffffff';
}else{
event.currentTarget.style. background Color = '#840029';
event.currentTarget.style. color = '#ffffff';
}
break;
case "mouseout":
if( document.all )
{ window.event.srcElement.st yle.backgr oundColor = '#948463';
window.event.srcElement.st yle.color = '#ffffff';
}else{
event.currentTarget.style. Background Color = '#948463';
event.currentTarget.style. color = '#ffffff';
}
break;
default:break;
}
}
basically this code work with both Netscape and IE.
Now in your html file, you should make a reference to the root.js file like this:
<script language="JavaScript" src="lib/root.js"></script >
then in your body, on the cell that you want to change the color you do this
<td align=center class=greyTd onmouseover="MouseEffect(e vent);" onMouseOut="MouseEffect(ev ent);" onClick="ChangePage('About us.htm');" >About me</td>
greyTd is just my css.
This will work for you. To see this page in effect check this link
http://www.jk2design.com/Gallery.htm
regards,
iz.
create a file called root.js and put this code in it:
function MouseEffect( event )
{ switch( event.type )
{ case "mouseover":
if( document.all )
{ window.event.srcElement.st
window.event.srcElement.st
}else{
event.currentTarget.style.
event.currentTarget.style.
}
break;
case "mouseout":
if( document.all )
{ window.event.srcElement.st
window.event.srcElement.st
}else{
event.currentTarget.style.
event.currentTarget.style.
}
break;
default:break;
}
}
basically this code work with both Netscape and IE.
Now in your html file, you should make a reference to the root.js file like this:
<script language="JavaScript" src="lib/root.js"></script
then in your body, on the cell that you want to change the color you do this
<td align=center class=greyTd onmouseover="MouseEffect(e
greyTd is just my css.
This will work for you. To see this page in effect check this link
http://www.jk2design.com/Gallery.htm
regards,
iz.
thanks Daydreams ;)
ASKER