鼠标事件例子
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>鼠标事件</title>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function() {
$("input[type='button']")
.css("width", "280px")
.css("height", "100px")
.css("font-size", "24pt");
});
function fnOver() {
$("h1").html("鼠标移动到按钮上了!");
}
function fnOut() {
$("h1").html("鼠标移开了!");
}
function fnMove() {
$("div").text(event.x + "," + event.y);
}
</script>
</head>
<body>
<h1></h1>
<input type="button" value="测试悬停" onmouseover="fnOver();" onmouseout="fnOut();" />
<input type="button" value="测试点击" onclick="$('h1').html('点击了鼠标!');" />
<input type="button" value="测试双击" ondblclick="$('h1').html('双击了鼠标!');" />
<input type="button" value="测试鼠标按键" onmousedown="$('h1').html('按下了鼠标!');" onmouseup="$('h1').html('松开了鼠标!');" />
<div style="border: double 3px red;width: 400px; height: 300px;" onmousemove="fnMove();">
</div>
</body>