|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
OnMouseOver bgColor change with id
ok here's what im looking for.. I want the background of multiple tables to change when a mouseover is activated..
right now I have this: <td id="ql1" onmouseover="ql1.bgColor='#FFFFFF'"> but it doesnt seem to work.. does anyone know what I should change? thanks in advance ![]() |
|
#2
|
|||
|
|||
|
Code:
<td id="ql1" onmouseover="this.style.backgroundColor = '#fff';"> Hope that helps! Happy coding! ![]() |
|
#3
|
|||
|
|||
|
no.. as I said I want it to change the color for multiple tables when onmouseover is active.. so when onmouseover is activated it changes the bg color on all tables that have id="ql1"
|
|
#4
|
||||
|
||||
|
but only one element can have the id ql1,
id must be unique, within a document http://www.w3.org/TR/1998/REC-html4...al.html#h-7.5.2 |
|
#5
|
|||
|
|||
|
<table id="ql0" class="standard" onMouseover="goChange(1,'ql')">...</table>
<table id="ql1" class="standard" onMouseover="goChange(1,'ql')">...</table> function goChange(numOf,id) { for(i = 0; i <= numOf; i++) { temp = eval("document.getElementById('"+id+numOf+"')"); temp.className = 'highlight'; } } And setup two css classes called standard & highlight. It's not a perfect solution, but should give you groundwork to expand on. -D |
|
#6
|
|||
|
|||
|
hmm.. so now I have this:
Code:
<html>
<head>
<style type="text/css">
.highlight
{
color:#FFFFFF;
}
.normal
{
}
</style>
<script language="JavaScript">
<!--
function goChange(numOf,id) {
for(i = 0; i <= numOf; i++) {
temp = eval("document.getElementById('"+id+numOf+"')");
temp.className = 'highlight';
}
}
//-->
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td id="ql0" class="standard" onMouseover="goChange(2,'ql')" onmouseout="this.bgColor=''">td 1</td>
<td id="ql1" class="standard" onMouseover="goChange(2,'ql')" onmouseout="this.bgColor=''">td 2</td>
<td id="ql2" class="standard" onMouseover="goChange(2,'ql')" onmouseout="this.bgColor=''">td 3</td>
</tr>
</table>
</body>
</html>
but then nothing happens.. what am I doing wrong? edit: sorry should have used "background-color", but now it still only changes the bg color for the last table.. (ql2) Last edited by Sc0rp : December 27th, 2003 at 01:28 PM. |
|
#7
|
|||
|
|||
|
nvm that either..
![]() temp = eval("document.getElementById('"+id+numOf+"')"); should have been temp = eval("document.getElementById('"+id+i+"')"); thanks mate.. ![]() |
|
#8
|
|||
|
|||
|
Glad it worked.
-D |
|
#9
|
|||
|
|||
|
Quote:
You Rule! it works great! |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > OnMouseOver bgColor change with id |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|