js判断鼠标双击单击

<input type="button" onclick="aa()" ondblclick="bb()" value="点我">
<script language="javascript">
var isdb;
function aa(){
    isdb=false;
    window.setTimeout(cc, 500)
    function cc(){
        if(isdb!=false)return;
        alert("单击")
    }
}
function bb(){
    isdb=true;
    alert("双击")
}
</script>

 

 

-----------------------------------------------------------------

<a   href= "javascript:void(0) "   onclick= "test() "   ondblclick= "test() "> Click   Me </a> 
<script> 
function   test() 

if(event.type   ==   "dblclick")     document.all.mxh.innerText   =   "你双击了我 " 
if(event.type   ==   "click")   document.all.mxh.innerText   =   "你单击了我 " 

</script> 
<p> <p> <p> <p> 
<div   id=mxh> </div>

你可能感兴趣的:(JavaScript)