编辑下面的代码:【加编码】
<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()函数,该函数修改文本样式为红色。 在鼠标松开时触发 mouseUp()函数,该函数修改文本样式为绿色。 </p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂