jQuery How to fire the drag event while mouse is still down

前端 未结 4 891
南旧
南旧 2021-01-20 03:23

Ok I\'ve been playing around with this for hours now and still no dice. I\'m creating an interface allowing you to drag and drop an icon(a div with an image inside). I\'m us

4条回答
  •  再見小時候
    2021-01-20 03:47

    The concept of creating a clone which is to be dragged is already implemented in the draggable plugin. You should have used it like so:

    $('#tester').draggable({helper: 'clone', appendTo: 'body'});
    

    The appendTo option represents the element where you want the helper to be created

    You can hide your initial dragged object on dragstart (or leave it there if you desire) Here is a jsFiddle I made as a sample: http://jsfiddle.net/HnpbX/6/

    If you want to achieve a functionality of dragging and dropping an element from one container to another, you should use the droppable in combination with draggable

提交回复
热议问题