运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <p id="p1" onmousedown="mouseDown()" onmouseup="mouseUp()"> Click the text! The mouseDown() function is triggered when the mouse button is pressed down over this paragraph. The function sets the color of the text to red. The mouseUp() function is triggered when the mouse button is released. The mouseUp() function sets the color of the text to green. </p> <script> function mouseDown() { document.getElementById("p1").style.color = "red"; } function mouseUp() { document.getElementById("p1").style.color = "green"; } </script> </body> </html>