jQuery UI & Draggable: Default funtionality

This entry is part 2 of 11 in the series jQuery UI Draggable

jQuery UI Draggable – Default functionality

Enable draggable functionality on any DOM element.

Move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport.

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>jQuery UI Draggable - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  #draggable { width: 150px; height: 150px; padding: 0.5em; }
  $(function() {
    $( "#draggable" ).draggable();
<div id="draggable" class="ui-widget-content">
  <p>Drag me around</p>
Try The Code

The class ui-widget-content is one of the list of classes used by jQuery UI. The classes are designed to create a visual consistency across an application. 

The class ui-widget-content provides styling for content box.

Other jQuery UI classes are listed here.

Series Navigation<< jQuery UI: Introduction
jQuery UI & Draggable: Constrain movement >>

Leave a comment

Leave a Reply