How to make mouse double click in JavaScript?

后端 未结 3 1063
说谎
说谎 2021-01-25 13:50

I need a JavaScript code to make mouse double click by itself. I will use it inside my Java code . This one is a selenium project for testing-purposes but there is not any way t

3条回答
  •  暖寄归人
    2021-01-25 14:33

    As Mozfet says JQuery ! it's so easy with JQuery ! 
    
    $("#myId").trigger('dblclick');
    
    then you listen for this double click 
    $("#myId").on('dblclick',function(){
    // do it !
    });
    
    // you can event make you own event 
    $("#myId").trigger('retrieve');
    
    then you listen for this custom event 
    $("#myId").on('retrieve',function(){
    // do it !
    });
    

    I often use it in datatables : I've got a popover (a small menu on the left td of each row) if the user choose "open modal" i then trigger a double click which goes to the table which is already waiting for a double click from the user on the row. So i don't need to implement 2 events

提交回复
热议问题