<!DOCTYPE html> <html> <head> <script> function mouseDown() { document.getElementById("p1").style.color="red"; } function mouseUp() { document.getElementById("p1").style.color="green"; } </script> </head> <body> <p id="p1" onmousedown="mouseDown()" onmouseup="mouseUp()"> 請點擊文本!mouseDown() 函數當鼠標button在段落上被按下時觸發。
此函數把文本顏色設置為紅色。mouseUp() 函數在鼠標button被釋放時觸發。mouseUp() 函數把文本的顏色設置為綠色。
</p> </body> </html>