|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hi I have a simple code like:
Code:
<table width="624" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="293" height="181" valign="top" bgcolor="#FF0000" onMouseOver="this.bgColor='#000000'" onMouseout="this.bgColor='#FF0000'" onClick="this.bgColor='#00FF00'"></td>
<td width="331" valign="top" bgcolor="#FF0000" onMouseOver="this.bgColor='#000000'" onClick="this.bgColor='#00FF00'"></td>
</tr>
<tr>
<td height="183" valign="top" bgcolor="#FF0000"></td>
<td valign="top" bgcolor="#FF0000"></td>
</tr>
</table>
in my 2*2 table: the upper left corner i have onMouse and onClick events which i have trouble about them... the original of the upper left is red when i go over it with mouse it becomes black. When i click it becomes green but if I move the mouse from over the cell it then becomes to its original color red. How can i make a thing like: when i click the mouse it becomes green and stay green if i press another cell then this new one becomes green and the previous one becomes the original(red)??? Thanx in advance... |
|
#2
|
||||
|
||||
|
To make life easier, you could assign an ID your your cells. It is then easier to refernce your ID using the getElementById() function.
Using CSS to control the color/style will also make things easier. e.g. <td onMouseOver="this.style.className='on'" onMouseOut="this.style.className='off'"> |
|
#3
|
|||
|
|||
|
ahh crap, your telling me you can define a class dynamically with JS! crap, that would have saved me so much time. I tried id.class, which didnt work!
*kicks himself! |
|
#4
|
||||
|
||||
|
lol - that woulda been some slow, clunky code, setting different style atributes seperately....
|
|
#5
|
|||
|
|||
|
yes, i basically defined each stylesheet atribute!
crap, crap, crap! lol, now i just feel stupid. It only took me 4 years to find that one out |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > a table cell problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|