Bonjour.
Je voudrais modifier la couleur et la taille du texte avec onmouseover.
J'arrive a modifier un attribut mais pas deux!!
merciCode:<span onclick="valider(42)" onmouseover="this.style.color='red'" >Alsace</span>
Version imprimable
Bonjour.
Je voudrais modifier la couleur et la taille du texte avec onmouseover.
J'arrive a modifier un attribut mais pas deux!!
merciCode:<span onclick="valider(42)" onmouseover="this.style.color='red'" >Alsace</span>
A l'arrache
Mais tu peux aussi faire une fonction pour ça, c'est beaucoup plus propre.Code:<span onclick="valider(42)" onmouseover="this.style.color='red';this.style.backgroundColor='blue'" >Alsace</span>
hi,
sous FF ca marche!Code:<span onclick="valider(42)" onmouseover="this.style.color='red';this.style.fontSize='1.2em';" >Alsace</span>
En gro on remplace le "-x" des attribut css par "X" en javascript
exemple:
font-family donne en javascript : fontFamily
font-size donne en javascript : fontSize
font-weight donne en javascript : fontWeight
J'espere t'avoir aidé nanPêche :p
Bon merci ça marche mais comment je peux ecrire une fonction avec ça?:oops:
Ca m'arrangerait bien j'ai 23 lignes à écrire:cry:Code:onmouseover="this.style.color='red'; this.style.fontSize='12px';" onmouseout="this.style.color='black'; this.style.fontSize='10px';">Alsace
bonjour,
tout simplement :
mets les instructions les unes à la suite des autres.Code:
1
2 <span onclick="valider(42)" onmouseover="this.style.color='red'; this.style.fontWeight='bold'" >Alsace</span>
Par contre si tu dois en rajouter un peu plus, créée une fonction ou une nouvelle classe :
----------------------------------------Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <html> <head> <title></title> <style type="text/css"> <!-- .classMouseOver{ color: #FF0000; font-weight: bold; } //--> </style> </head> <body> <span onclick="valider(42)" onmouseover="this.className='classMouseOver'" >Alsace</span> </body> </html>
Plus propre utilise la balise <a> :
>pas besoin de onmouseover() ou de onmouseout(). N'oublie pas le mot-clef javascript dans le href.Code:
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 <html> <head> <title></title> <style type="text/css"> <!-- a:hover{ color: #FF0000; font-weight: bold; } //--> </style> <script type="text/javascript"> <!-- function valider(n) { alert(n); } //--> </script> </head> <body> <a href="javascript:valider(42)">Alsace</a> </body> </html>