Colorare testo su click





' Clicca il testo! La funzione mouseDown () viene attivata quando il pulsante del mouse viene premuto su questo paragrafo e imposta il colore del testo su rosso. La funzione mouseUp () viene attivata quando viene rilasciato il pulsante del mouse e imposta il colore del testo su verde.



<!DOCTYPE html>
<html>
<body>

<p id="myP" onmousedown="mouseDown()" onmouseup="mouseUp()">
Click the text! The mouseDown() function is triggered when the mouse button is pressed down over this paragraph, and sets the color of the text to red. The mouseUp() function is triggered when the mouse button is released, and sets the color of the text to green.
</p>

<script>
function mouseDown() {
document.getElementById("myP").style.color = "red";
}

function mouseUp() {
document.getElementById("myP").style.color = "green";
}
</script>

</body>
</html>













( coloraretestosuclick.html )- by Paolo Puglisi - Modifica del 17/12/2023