日期:2014-05-16  浏览次数:20372 次

jquery的click事件怎么按时间触发
当点击图片的时候,如果点击(单击)的时间不够2秒就不触发jquery的click事件怎么实现,请大家帮忙看下。谢谢。
jquery 图片

------解决方案--------------------
引用:
Quote: 引用:

你是说鼠标按住>2s ?



是,小于不触发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="" />
</body>
</html>