代码示例:(标识:eg_js_dom_event_onmousedown)
<!DOCTYPE html>
<html>
<head>
<script>
function lighton() {
  document.getElementById('myimage').src = "/static/demo/images/eg_bulbon.gif";
}
function lightoff() {
  document.getElementById('myimage').src = "/static/demo/images/eg_bulboff.gif";
}
</script>
</head>

<body>

<img id="myimage" onmousedown="lighton()" onmouseup="lightoff()" src="/static/demo/images/eg_bulboff.gif" />

<p>点击鼠标并按住!</p>

</body>
</html>
运行结果: