Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1310 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Modifier le style CSS d'un tableau par rollover

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Modifier le style CSS d'un tableau par rollover

n°162219
kalios
Prout !
Posté le 19-06-2002 à 01:35:09  profilanswer
 

J'utilise dans un menu des cellules d'un tableau comme bouton.  
 
Je modifie le style du bouton directement aux évenements OnMouse
de cette manière : this.className='button_up'
 
ceci fonctionne parfaitement pour modifier le style de la cellule sur laquel la souris se trouve.
 
Mon problème réside dans le fait que je souhaite modifier tout la ligne de cellules en même temps comment puis-je faire ?
 
Je ne peux malheureusement pas modifier le style de la balise <TR> mais seulement celui de la balise de cellule <TD> pour que mon effet de style fonctionne.
 
Avez-vous une solution ?

mood
Publicité
Posté le 19-06-2002 à 01:35:09  profilanswer
 

n°162369
fastclemmy
(re-)Dictateur en plastique
Posté le 19-06-2002 à 11:20:42  profilanswer
 

Ils font ça dans la dernière version de PHPMyAdmin :
 

Code :
  1. <tr onmouseover="setPointer(this, 'over', '#DDDDDD', '#CCFFCC', '#FFCC99')" onmouseout="setPointer(this, 'out', '#DDDDDD', '#CCFFCC', '#FFCC99')" onmousedown="setPointer(this, 'click', '#DDDDDD', '#CCFFCC', '#FFCC99')">


 

Code :
  1. function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
  2. {
  3.     var theCells = null;
  4.     // 1. Pointer and mark feature are disabled or the browser can't get the
  5.     //    row -> exits
  6.     if ((thePointerColor == '' && theMarkColor == '')
  7.         || typeof(theRow.style) == 'undefined') {
  8.         return false;
  9.     }
  10.     // 2. Gets the current row and exits if the browser can't get it
  11.     if (typeof(document.getElementsByTagName) != 'undefined') {
  12.         theCells = theRow.getElementsByTagName('td');
  13.     }
  14.     else if (typeof(theRow.cells) != 'undefined') {
  15.         theCells = theRow.cells;
  16.     }
  17.     else {
  18.         return false;
  19.     }
  20.     // 3. Gets the current color...
  21.     var rowCellsCnt  = theCells.length;
  22.     var domDetect    = null;
  23.     var currentColor = null;
  24.     var newColor     = null;
  25.     // 3.1 ... with DOM compatible browsers except Opera that does not return
  26.     //         valid values with "getAttribute"
  27.     if (typeof(window.opera) == 'undefined'
  28.         && typeof(theCells[0].getAttribute) != 'undefined') {
  29.         currentColor = theCells[0].getAttribute('bgcolor');
  30.         domDetect    = true;
  31.     }
  32.     // 3.2 ... with other browsers
  33.     else {
  34.         currentColor = theCells[0].style.backgroundColor;
  35.         domDetect    = false;
  36.     } // end 3
  37.     // 4. Defines the new color
  38.     // 4.1 Current color is the default one
  39.     if (currentColor == ''
  40.         || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
  41.         if (theAction == 'over' && thePointerColor != '') {
  42.             newColor = thePointerColor;
  43.         }
  44.         else if (theAction == 'click' && theMarkColor != '') {
  45.             newColor = theMarkColor;
  46.         }
  47.     }
  48.     // 4.1.2 Current color is the pointer one
  49.     else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
  50.         if (theAction == 'out') {
  51.             newColor = theDefaultColor;
  52.         }
  53.         else if (theAction == 'click' && theMarkColor != '') {
  54.             newColor = theMarkColor;
  55.         }
  56.     }
  57.     // 4.1.3 Current color is the marker one
  58.     else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
  59.         if (theAction == 'click') {
  60.             newColor = (thePointerColor != '')
  61.                      ? thePointerColor
  62.                      : theDefaultColor;
  63.         }
  64.     } // end 4
  65.     // 5. Sets the new color...
  66.     if (newColor) {
  67.         var c = null;
  68.         // 5.1 ... with DOM compatible browsers except Opera
  69.         if (domDetect) {
  70.             for (c = 0; c < rowCellsCnt; c++) {
  71.                 theCells[c].setAttribute('bgcolor', newColor, 0);
  72.             } // end for
  73.         }
  74.         // 5.2 ... with other browsers
  75.         else {
  76.             for (c = 0; c < rowCellsCnt; c++) {
  77.                 theCells[c].style.backgroundColor = newColor;
  78.             }
  79.         }
  80.     } // end 5
  81.     return true;
  82. } // end of the 'setPointer()' function


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Modifier le style CSS d'un tableau par rollover

 

Sujets relatifs
XML, CSS, les images et les liens[CSS] heritage?
masquer et afficher des cellules de tableau avec les div??[[[HTML]]]Merci de m'aider à insérer une image en fond dans un tableau
recupere la valeur d'un propiete de style avec DOM[HTML, JS] Pb de rollover...
[CSS] Possibilité de deux "décorations" de texte à la fois ?[C++] Need freeware style Winzip
HTML/Javascript : modifier la couleur d'un champ texte... MARCHE!Problème avec un tableau à deux dimensions !
Plus de sujets relatifs à : Modifier le style CSS d'un tableau par rollover


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR