首页javascriptmousejQuery Event - 如何句柄双击事件...

jQuery Event - 如何句柄双击事件...

我们想知道如何句柄双击事件。...

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    function handler() {
        console.log('hi');
        bind();
    }
    function bind() {
        var whatHandler = Math.random() > 0.5 ? 'dblclick' :'click';
        $('div').unbind('.test').bind(whatHandler + '.test', handler);
    }
    $(function() {
       bind();
    });
});
</script>
</head>
<body>
  <div>click me</div>
</body>
</html>