<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("input").mousedown(function() {
var flag = false;
var stop;
stop = setTimeout(function() {//down 1s,才运行。
flag = true;
alert("开始处理你的代码.");
}, 1000);
$("input").mouseup(function() {//鼠标up时,判断down了多久,不足一秒,不执行down的代码。
if (!flag) {
clearTimeout(stop);
}
});
});
});
</script>
</head>
<body>
<input value="按住我1秒钟才行" />
</body>
</html>