jQuery - Interaction Drag-able


The Drag-able function can be used with interactions in JqueryUI.This function can enable drag-able functionality on any DOM element.We can drag the drag-able element by clicking on it with mouse.


Here is the simple syntax to use drag-able −

 $( "#draggable" ).draggable();


Following is a simple example showing the usage of drag-able −

Live Demo
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      <script type = "text/javascript" language = "javascript">
         $(function() {
            $( "#draggable" ).draggable();
         #draggable { width: 150px; height: 150px; padding: 0.5em; }
            background-color: lightgrey;
            width: 50px;
            padding: 25px;
            border: 25px solid navy;
            margin: 25px;
      <div id = "draggable" class = "ui-widget-content">
         <p class = "back">Drag</p>

This will produce following result −