x
 
<!DOCTYPE html>
<html>
<body>
<p>本例使用 HTML DOM 将 "mousedown" 和 "mouseup" 事件附加到 p 元素。</p>
<p id="demo">点击我.</p>
<script>
document.getElementById("demo").onmousedown = function() {mouseDown()};
document.getElementById("demo").onmouseup = function() {mouseUp()};
function mouseDown() {
  document.getElementById("demo").innerHTML = "The mouse button is held down.";
}
function mouseUp() {
  document.getElementById("demo").innerHTML = "You released the mouse button.";
}
</script>
</body>
</html>