案例:html/html5 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script>
5
function mouseDown()
6
{
7
document.getElementById("p1").style.color="red";
8
}
9
10
function mouseUp()
11
{
12
document.getElementById("p1").style.color="green";
13
}
14
</script>
15
</head>
16
<body>
17
18
<p id="p1" onmousedown="mouseDown()" onmouseup="mouseUp()">
19
请点击文本!mouseDown() 函数当鼠标按钮在段落上被按下时触发。此函数把文本颜色设置为红色。mouseUp() 函数在鼠标按钮被释放时触发。mouseUp() 函数把文本的颜色设置为绿色。
20
</p>
21
22
</body>
23
</html>
24