87,907
社区成员
发帖
与我相关
我的任务
分享
<html>
<body>
<style>
td{background:#f60;padding:20px;}
</style>
<table>
<tr>
<td>1</td>
</tr>
</table>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>
var timer1 = timer2 = null
$("table").on("click","tr",function(e){
clearTimeout(timer1)
timer1 = setTimeout(function(){
console.log("单击了tr")
},300)
})
$("table").on("click","td",function(e){
clearTimeout(timer2)
timer2 = setTimeout(function(){
console.log("单击了td")
},300)
})
$("table").on("dblclick","tr",function(e){
clearTimeout(timer1)
clearTimeout(timer2)
console.log("双击了tr")
})
$("table").on("dblclick","td",function(e){
clearTimeout(timer1)
clearTimeout(timer2)
e.stopPropagation()
console.log("双击了td")
})
</script>
</body>
</html>