PDA

View Full Version : MouseOver Tabella in JavaScript


Pro7on
07-02-2006, 10:38
Ciao a tutti, allora dovrei cambiare il background di una cella (che è in una tabella) con il pasaggio del mouse.
:confused:

Ciau


....

<table width="600" height="400" border="1" class="tabella">
<tr>
<td id="1" height="50" width="100" onMouseOver="over();">???</td>


...

tglman
07-02-2006, 16:28
Probabilmente ti basta fare solo questo
<table width="600" height="400" border="1" class="tabella">
<tr>
<td id="1" height="50" width="100" onMouseOver="over(this);">???</td>

ma dovrei vedere il codice javscript della funzione

Pro7on
08-02-2006, 08:08
Probabilmente ti basta fare solo questo
<table width="600" height="400" border="1" class="tabella">
<tr>
<td id="1" height="50" width="100" onMouseOver="over(this);">???</td>

ma dovrei vedere il codice javscript della funzione


e quello il probblema :D !

se me lo trovi mi fai un favore :) Thx Ciao

Pro7on
08-02-2006, 13:30
e quello il probblema :D !

se me lo trovi mi fai un favore :) Thx Ciao
:muro: :confused: :rolleyes: :(

kk3z
08-02-2006, 16:59
Con una ricerca su google ho trovato:

<script type="text/javascript">
<!--
function setPointer(theRow, thePointerColor)
{
if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
return false;
}
if (typeof(document.getElementsByTagName) != 'undefined') {
var theCells = theRow.getElementsByTagName('td');
}
else if (typeof(theRow.cells) != 'undefined') {
var theCells = theRow.cells;
}
else {
return false;
}

var rowCellsCnt = theCells.length;
for (var c = 0; c < rowCellsCnt; c++) {
theCells[c].style.backgroundColor = thePointerColor;
}

return true;
} // end of the 'setPointer()' function
//-->
</script>

uso:
<td style="background-color:#cccccc" onMouseOver="setPointer(this, '#ffffff');" onMouseOut="setPointer(this, '#cccccc');">???</td>

Oppure puoi farlo direttamente:
<td style="background-color:#cccccc" onmouseover="style.backgroundColor='#ffffff;"
onmouseout="style.backgroundColor='#cccccc'">