How to differentiate between click and drag/drop event?

前端 未结 5 982
梦毁少年i
梦毁少年i 2021-02-15 23:23

I have a problem with element which is both draggable and also has a click event.

$(\'.drag\').mousedown(function() {
    //...
});

$(\'.class\').click(function         


        
5条回答
  •  故里飘歌
    2021-02-16 00:28

    You should be able to do that by stopping the propagation on the mousedown event.

    $('.drag').mousedown(function(event){
      event.stopPropagation();
    });  
    

    You may have to make sure that this event is attached before the click event though.

提交回复
热议问题