1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
var gestionTD=
{
colorOver : "red",//METTRE ICI LA COULEUR DESIREE AU PASSAGE DE LA SOURIS
colorOld : "",
recuperation: function(table)
{
if(table != undefined)
{
if(document.getElementById(table))
{
this.tab=document.getElementById(table).getElementsByTagName('TD');
}
else
{
alert('Le choix de la table n\'existe pas !');return;
}
}
else
{
this.tab=document.body.getElementsByTagName('TD');
}
this.associerEvenements();
},
associerEvenements : function()
{
for(var i=0; i< this.tab.length; i++)
{
if(document.all)//POUR IE
{
this.tab[i].setAttribute('onmouseover',function(){gestionTD.colorer(this);} );
this.tab[i].setAttribute('onmouseout',function(){gestionTD.decolorer(this);} );
}
else //FF ET LES AUTRES
{
this.tab[i].onmouseover =function() {gestionTD.colorer(this);};
this.tab[i].onmouseout =function() {gestionTD.decolorer(this);};
}
}
},
colorer : function(td)
{
this.colorOld=td.style.backgroundColor;
td.style.backgroundColor =gestionTD.colorOver ;
},
decolorer:function (td)
{
td.style.backgroundColor =gestionTD.colorOld;
}
};
gestionTD.recuperation(id);//Mettre le id de la table concernée par la gestion des td ou si on ne mets rien, tous les td du body seront concernés |
Partager