Rolleover sur du texte

Résolu
ox3d -  
 ox3d -
Bonjour,

Je voudrait faire que , un texte inscrit dans une cellule , change en couleur A en passant dessus, en couleur B en un clic et C en deux clic .

Merci pour votre aide

16 réponses

  1. tapion76 Messages postés 3820 Date d'inscription   Statut Membre Dernière intervention   888
     
    OK

    Pas spécialiste de ce genre de logiciel.
    Je code à la main
    Je laisse place donc...
    1
  2. tapion76 Messages postés 3820 Date d'inscription   Statut Membre Dernière intervention   888
     
    Bonjour,

    Faudrait déjà dire sur quelle logiciel
    0
  3. ox3d
     
    Oups

    je bricole sur Kompozer une fiche pour mon boulot en HTML
    0
  4. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  5. Utilisateur anonyme
     
    salut, tu peux faire une chose de ce style qui sera à adapter :

    
    <body>
    		<p id="montext">
    			salut
    		</p>
    		<script type="text/javascript">
    			var tex = document.getElementById("montext");
    			tex.onmouseover = function() {
    				tex.style.color = "red";
    			}
    
    			tex.onclick = function() {
    				tex.style.color = "green";
    			}
    
    			tex.ondblclick = function() {
    				tex.style.color = "yellow";
    			}
    		</script>
    	</body>
    

    0
  6. jjaco Messages postés 575 Statut Membre 45
     
    dans la feuille de style CSS tu peux mettre
    p:hover{color:red;}
    pour colorer le texte en rouge au survol
    0
  7. ox3d
     
    C'est presque bon pour ce code sauf que si je passe sur le texte il doit passer par exemple en rouge comme l'exemple mais si je me déplace en dehors du texte il doit revenir en noir , sur un clic il devient et doit reste vert , même si je repasse dessus , et avec deux clics il passe et doit rester en jaune même si je repasse dessus , il ne changera de couleur que si je re-clic dessus .

    Je sais pas si c'est clair tous çà ....

    un texte est noir , devient rouge au survole , vert si je clic un fois , jaune pour deux clics , mais ne change plus si je le re-survole.
    0
  8. Utilisateur anonyme
     
    salut

    <body>
    		<p id="montext">
    			salut
    		</p>
    		<script type="text/javascript">
    			var tex = document.getElementById("montext");
    			tex.onmouseover = function() {
    				if (tex.style.color == "green" || tex.style.color == "yellow") {
    					return false;
    				} else {
    					tex.style.color = "red";
    				}
    			}
    			tex.onmouseout = function() {
    				if (tex.style.color == "green" || tex.style.color == "yellow") {
    					return false;
    				} else {
    					tex.style.color = "black";
    				}
    			}
    
    			tex.onclick = function() {
    				if (tex.style.color == "yellow") {
    					return false;
    				} else {
    					tex.style.color = "green";
    				}
    			}
    
    			tex.ondblclick = function() {
    				tex.style.color = "yellow";
    			}
    		</script>
    	</body>
    
    

    0
  9. ox3d
     
    C'est super Merci , juste un détail .

    Si j'ai cliqué une fois il passe donc vert , deux il passe jaune , mais si je re-clic une fois , ne peut il pas repasser vert ... ( si j'ai cliqué deux fois par erreur par exemple , ou si j'ai changé d'avis )
    0
  10. Utilisateur anonyme
     
    voila essaye ceci et dit moi

    <body>
    		<p id="montext">
    			salut
    		</p>
    		<script type="text/javascript">
    			var tex = document.getElementById("montext");
    			tex.onmouseover = function() {
    				if (tex.style.color == "green" || tex.style.color == "yellow") {
    					return false;
    				} else {
    					tex.style.color = "red";
    				}
    			}
    			tex.onmouseout = function() {
    				if (tex.style.color == "green" || tex.style.color == "yellow") {
    					return false;
    				} else {
    					tex.style.color = "black";
    				}
    			}
    
    			tex.onclick = function() {
    				
    					tex.style.color = "green";
    			
    			}
    
    			tex.ondblclick = function() {
    				tex.style.color = "yellow";
    			}
    		</script>
    	</body>
    
    

    0
  11. ox3d
     
    C'est ça , c'est NICKEL

    Y a pas ... Quand on s'adresse à des bons , on à du bon boulot

    Merci

    Un autre petit truc, pourquoi , mes pages HTML ne sont pas identiques suivant les support comme google , firefox , chrome .....
    0
  12. Utilisateur anonyme
     
    Salut, souvent ce problème est surtout avec explorer. Sa vient que les navigateurs interprètent différemment le code. C'est à toi avec tes CSS de faire en sorte que se soit identique ou alors convenablement suffisant.
    0
  13. ox3d
     
    Bon je comprend pas tout mais merci pour ton code ;)

    Peut être serai-je amené à revenir par ici
    0
    1. Utilisateur anonyme
       
      ok pas de souci le forum est là pour ça :)

      pense à mettre résolu
      0
  14. ox3d
     
    Re salut

    Bon j'ai un autre problème, c'est que ce code je voudrai l'appliquer à plusieurs texte , mais le résultat c'est que je veux que chaque texte changent pas uniquement le dernier

    L'idée, c'est une checklist, c'est qu'une fois validé le texte1 en vert ou jaune , je puisse faire valider le texte2 ou 36 , ou 122 puis revenir su le 4 ou 68.

    et la çà fonctionne pas terrible puisque c'est toujpours le texte4 qui change

    Merci pour votre aide


    <body style="height: 27px;">
    <table style="text-align: left; height: 23px; width: 393px;" border="1"
    cellpadding="2" cellspacing="2">
    <tbody>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: middle; height: 17px; width: 137px;">
    <p style="margin-top: 1px; height: 4px;" id="montext1">TEXTE1 </p>
    <script type="text/javascript">
    var tex = document.getElementById("montext1");
    tex.onmouseover = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "red";
    }
    }
    tex.onmouseout = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "black";
    }
    }
    tex.onclick = function() {
    tex.style.color = "green";
    }
    tex.ondblclick = function() {
    tex.style.color = "yellow";
    }
    </script></td>
    <td style="vertical-align: top; width: 249px;">
    <p style="margin-top: 1px; height: 4px;" id="montext5">TEXTE5 </p>
    <script type="text/javascript">
    var tex = document.getElementById("montext5");
    tex.onmouseover = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "red";
    }
    }
    tex.onmouseout = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "black";
    }
    }
    tex.onclick = function() {
    tex.style.color = "green";
    }
    tex.ondblclick = function() {
    tex.style.color = "yellow";
    }
    </script></td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;">
    <p style="margin-top: 1px; height: 4px;" id="montext2">TEXTE2 </p>
    <script type="text/javascript">
    var tex = document.getElementById("montext2");
    tex.onmouseover = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "red";
    }
    }
    tex.onmouseout = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "black";
    }
    }
    tex.onclick = function() {
    tex.style.color = "green";
    }
    tex.ondblclick = function() {
    tex.style.color = "yellow";
    }
    </script></td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;">
    <p style="margin-top: 1px; height: 4px;" id="montext3">TEXTE3 </p>
    <script type="text/javascript">
    var tex = document.getElementById("montext3");
    tex.onmouseover = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "red";
    }
    }
    tex.onmouseout = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "black";
    }
    }
    tex.onclick = function() {
    tex.style.color = "green";
    }
    tex.ondblclick = function() {
    tex.style.color = "yellow";
    }
    </script></td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;">
    <p style="margin-top: 1px; height: 4px;" id="montext4">TEXTE4 </p>
    <script type="text/javascript">
    var tex = document.getElementById("montext4");
    tex.onmouseover = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "red";
    }
    }
    tex.onmouseout = function() {
    if (tex.style.color == "green" || tex.style.color == "yellow") {
    return false;
    } else {
    tex.style.color = "black";
    }
    }
    tex.onclick = function() {
    tex.style.color = "green";
    }
    tex.ondblclick = function() {
    tex.style.color = "yellow";
    }
    </script></td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    <tr>
    <td style="vertical-align: top; width: 137px;"><br>
    </td>
    <td style="vertical-align: top; width: 249px;"><br>
    </td>
    </tr>
    </tbody>
    </table>
    <br>
    <br>
    </body>
    0
  15. Utilisateur anonyme
     
    salut, fais comme ceci :

    	<body>
    		<p class="montext">
    			salut 1
    		</p>
    		<p class="montext">
    			salut 2
    		</p>
    		<p class="montext">
    			salut 3
    		</p>
    		<p class="montext">
    			salut 4
    		</p>
    		<p class="montext">
    			salut 5
    		</p>
    		<p class="montext">
    			salut 6
    		</p>
    		<p class="montext">
    			salut 7
    		</p>
    		<p class="montext">
    			salut 8
    		</p>
    		<p class="montext">
    			salut 1
    		</p>
    		<p class="montext">
    			salut 9
    		</p>
    		<script type="text/javascript">
    			var tex = document.getElementsByClassName("montext");
    			for (var i = 0; i < tex.length; i++) {
    				tex[i].onmouseover = function() {
    					if (this.style.color == "green" || this.style.color == "yellow") {
    						return false;
    					} else {
    						this.style.color = "red";
    					}
    				}
    				tex[i].onmouseout = function() {
    					if (this.style.color == "green" || this.style.color == "yellow") {
    						return false;
    					} else {
    						this.style.color = "black";
    					}
    				}
    
    				tex[i].onclick = function() {
    
    					this.style.color = "green";
    
    				}
    
    				tex[i].ondblclick = function() {
    					this.style.color = "yellow";
    				}
    			}
    		</script>
    	</body>
    
    

    0
  16. ox3d
     
    encore un fois BINGO !!!!! merci LOBOTOFIX

    Un nom à retenir ;)
    0