HighDots Forums  

Re: any cell change color

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: any cell change color in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Evertjan.
 
Posts: n/a

Default Re: any cell change color - 08-03-2003 , 03:27 AM






JimsNews wrote on 03 aug 2003 in comp.lang.javascript:
Quote:
Using mouseover mouseout I want to be able to change cell bgcolors.
Example: A table with 3 rows and 2 columuns...

r1c1 r1c2
r2c1 r2c2
r3c1 r3c2

Example: I want r1c1, r2c1 and r2c2 bgcolor to all change to same
bgcolor when mouse is over any one of...
r1c1, r2c1 or r2c2
===================

<head>
<style id="TableStyle">
.r1 {background-color:;}
.r2 {background-color:;}
td {font-size:50pt;padding:40px;}
</style>

<script>
TableStyle.r1=document.styleSheets.TableStyle.rule s[0].style;
TableStyle.r2=document.styleSheets.TableStyle.rule s[1].style;

function over(x) {
cnme=x.className
TableStyle[cnme].backgroundColor='yellow';
}
function out(x) {
cnme=x.className
TableStyle[cnme].backgroundColor='';
}
</script>

</head><body>

<table id=t1 border=10><tr>
<td class=r1
onmouseover=over(this)
onmouseout=out(this)>
r1c1
</td>
<td class=r2
onmouseover=over(this)
onmouseout=out(this)>
r2c1
</td>
</tr><tr>
<td class=r1
onmouseover=over(this)
onmouseout=out(this)>
r1c2
</td>
<td class=r2
onmouseover=over(this)
onmouseout=out(this)>
r2c2
</td></tr><tr>
<td class=r1
onmouseover=over(this)
onmouseout=out(this)>
r1c3
</td>
<td class=r2
onmouseover=over(this)
onmouseout=out(this)>
r2c3
</td>
</tr></table>

</body>

===================

IE6 tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.