Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Ajax Jquery jQuery UI Interaction : Draggable

Related Tutorials


Share on Google+Share on Google+

jQuery UI Interaction : Draggable

This page discusses - jQuery UI Interaction : Draggable

jQuery UI Interaction : Draggable


jQuery UI Interaction : Draggable

Using jQuery UI draggable plugin , you can cause certain element draggable by mouse.

The element which are going to drag obtain a  'ui-draggable' class. This element obtain a 'ui-draggable-dragging'  class while dragging.

Also, if you want to drag and drop this element, you need to incorporate jQuery UI Droppable plugin, which provides a drop target for draggables.

All callbacks (start, stop, drag) receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):

  • ui.helper - the jQuery object representing the helper that's being dragged
  • ui.position - current position of the helper as { top, left } object, relative to the offset element
  • ui.offset - current absolute position of the helper as { top, left } object, relative to page


<!DOCTYPE html>
<link href=
/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="
<script src="
<style type="text/css">
#draggable { width: 100px; height: 70px; background: silver; }
$(document).ready(function() {
<body style="font-size:62.5%;">
<div id="draggable">Drag this box with mouse</div>

Output :

You can drag the box :

Download Source Code

Click here to see online demo

Learn from experts! Attend jQuery Training classes.


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Related Tutorials

Discuss: jQuery UI Interaction : Draggable  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image