Salve ragazzi! Volevo cambiare al volo uno stile senza ricorrere alla pseudoclasse hover con javascript.Ci sto sbattendo la testa da un po ma questo script non funge...
Sapete aiutarmi?
Codice PHP:[url="index.php"]Torna alla Home[/url]
Salve ragazzi! Volevo cambiare al volo uno stile senza ricorrere alla pseudoclasse hover con javascript.Ci sto sbattendo la testa da un po ma questo script non funge...
Sapete aiutarmi?
Codice PHP:[url="index.php"]Torna alla Home[/url]
Non capisco perche' usi gli escape... :master:
Torna alla Home
ciao
Il guaio per i poveri computers e' che sono gli uomini a comandarli.
Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
Consultate la discussione in rilievo: script / discussioni utili
Usate la funzione di Ricerca del Forum
cosi:Originariamente inviato da Erith
Salve ragazzi! Volevo cambiare al volo uno stile senza ricorrere alla pseudoclasse hover con javascript.Ci sto sbattendo la testa da un po ma questo script non funge...
Sapete aiutarmi?
Codice PHP:[url="index.php"]Torna alla Home[/url]
ho aggiunto anche l'evento onmouseout per dare l'effetto rollover.codice:Torna alla Home
Il mitico br1 e arrivato 1 (uno)![]()
Cavicchi Andrea
Problemi con javascript, jquery, ajax clicca qui
OoOOOOh grazie! Cmq avevo usato gli escape perchè originariamnete doveva essere una variabile PHP, molto sensibile agli apici nei doppi apici...
Grazie! (ps: per motivi di compatibilità devo preferire la pseudoclasse Hover o un javascript come questo?)![]()
Ciao.
Senza dubbio :hover.(ps: per motivi di compatibilità devo preferire la pseudoclasse Hover o un javascript come questo?)
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Già ma su explorer a volte ho problemi se la assegno ad un elemento che non è un link (ad esempio un div o un td)...
Si se lo devi usare anche su div etc
hai ragione ad ogni modo intercetando
IE (che come al solito è fatto a modo suo( )
puoi usare entranbi i metodi (se vai nella sezione
css trovi threads in proposito).
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Se no un metodo cross browser
è questo che utilizza js non intrusivo.
Codice estrapolato daCodice PHP:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
tr.over { background-color:#FFCC99}
tr.out { background-color:#66FF66}
</style>
<script language="JavaScript" type="text/JavaScript">
function init()
{
var nav=document.getElementById('target');
if(nav && nav.getElementsByTagName('tr')[0])
{
var tr = nav.getElementsByTagName('tr');
for(var i=0;i<tr.length;i++)
{
addEvent(tr[i],'mouseout',trOut,false);
addEvent(tr[i],'mouseover',trOver,false);
}
}
};
function cssjs(a,o,c1,c2)
{
switch (a)
{
case 'swap':
o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
break;
case 'add':
if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
break;
case 'remove':
var rep=o.className.match(' '+c1)?' '+c1:c1;
o.className=o.className.replace(rep,'');
break;
case 'check':
return new RegExp('\b'+c1+'\b').test(o.className)
break;
}
};
function addEvent(elm, evType, fn, useCapture){
if (elm.addEventListener)
{
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
}
function getTarget(e){
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target){return false;}
return target;
}
function trOver(e)
{
var trTarget = getTarget(e);
cssjs('swap',trTarget.parentNode,'over','out');
}
function trOut(e)
{
var trTarget = getTarget(e);
cssjs('swap',trTarget.parentNode,'out','over');
}
addEvent(window,'load',init, false);
</script>
</head>
<body>
<table id="target" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="out">
<td>PIPPO</td>
<td>CAIO</td>
<td>SEMP</td>
</tr>
<tr class="out">
<td>PIPPO</td>
<td>CAIO</td>
<td>SEMP</td>
</tr>
<tr class="out">
<td>PIPPO</td>
<td>CAIO</td>
<td>SEMP</td>
</tr>
<tr class="out">
<td>PIPPO</td>
<td>CAIO</td>
<td>SEMP</td>
</tr>
<tr class="out">
<td>PIPPO</td>
<td>CAIO</td>
<td>SEMP</td>
</tr>
</table>
</body>
</html>
qui
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it