Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and Drop using jQuery

Tags:

jquery

I want to do a simple drag-drop using jQuery. I have not done anything so far, but previous attempts were unsuccessful.

like image 431
X10nD Avatar asked Apr 12 '10 10:04

X10nD


People also ask

How drag and drop works in JavaScript?

The HTML Drag and Drop API relies on the DOM's event model to get information on what is being dragged or dropped and to update that element on drag or drop. With JavaScript event handlers, you can turn any element into a draggable item or an item that can be dropped into.

Can I use html5 drag and drop?

Now HTML 5 came up with a Drag and Drop (DnD) API that brings native DnD support to the browser making it much easier to code up. HTML 5 DnD is supported by all the major browsers like Chrome, Firefox 3.5 and Safari 4 etc.


2 Answers

Have you tried jQuery UI Draggable? Simple use case:

<script type="text/javascript">
    $(function() {
        $("#draggable").draggable();
    });
</script>

<div id="draggable" class="ui-widget-content">
    <p>Drag me around</p>
</div>
like image 163
karim79 Avatar answered Oct 17 '22 01:10

karim79


Online Demo Created.

See this please.

Other Option:

JQuery Drag & Drop Plugin.

like image 26
Sarfraz Avatar answered Oct 17 '22 01:10

Sarfraz