jquery的click事件怎么按时间触发
当点击图片的时候,如果点击(单击)的时间不够2秒就不触发jquery的click事件怎么实现,请大家帮忙看下。谢谢。 是,小于不触发click事件。
在图片区内,鼠标按住2s
<html>
<head>
<title>test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var tir=0;
$('img').mousedown(function() {
clearTimeout(tir);
tir = setTimeout(function() {
alert('ok');
}, 2000);
}).mouseup(function() {
clearTimeout(tir);
});
});
</script>
</head>
<body>
<img src="http://www.google.com.hk/images/srpr/logo4w.png" alt="jquery的click事件如何按时间触发" />
</body>
</html>