How to catch dragend event in JavaScript?

后端 未结 2 1965
挽巷
挽巷 2020-12-18 04:51

I\'m trying to catch the dragend event in JavaScript for a draggable DIV. The dragend event is not fired at all, why ? and how to solve this ? PS, I\'m using .draggable() me

相关标签:
2条回答
  • 2020-12-18 04:54

    In JavaScript and jQuery, when the user stops dragging the cursor, the event fired is: dragend.

    In jQuery UI, after calling .draggable();, when the user stops dragging the cursor, the event fired then becomes: dragstop. (Small demo showing that dragstop no longer works when .draggable() isn't called.)

    Documentation...

    JavaScript - dragend: Searching google for this produces about 100,000 search results, so this is likely what you'll be using. Source: MDN Web Docs: Document: dragend Event

    jQuery UI - dragstop: Searching for "jQuery UI Dragstop" produces only 5,000 search results at Google as of August, 2020. I can barely find any mention of it, but it is there in the Official jQuery UI Documentation: Draggable Widget.

    0 讨论(0)
  • 2020-12-18 05:17

    Try using dragstop instead of dragend

    .bind('dragstop',   function(){ $("#divId").text("drag ended");});
    
    0 讨论(0)
提交回复
热议问题