JS - onmouseup()-onmousedown()

<!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>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.