Click and double-click event firing

后端 未结 3 1332
长情又很酷
长情又很酷 2021-01-22 01:35

I\'m writing event handlers using jQuery, and had a question about the click and double-click events. I\'ve got an element with a class \"file\" on it. It has two event handlers

3条回答
  •  一整个雨季
    2021-01-22 02:11

    Dont trust the first answers, thats really really bad. Use this instead:

    $('.file').on('click', function()
    {
        $(this).css('background', 'blue');
    });
    
    $('.file').on('dblclick', function(event){
        event.preventDefault();
        $(this).css('background', 'green');                               
    });
    

    http://jsfiddle.net/H42KV/

提交回复
热议问题