jQuery: The Write Less, Do More JavaScript Library

UI/Draggables

From jQuery JavaScript Library

Jump to: navigation, search

« Back to the jQuery UI Docs

NameType
Dependencies:

  • ui.base.js

NameType

NameType
Plugin methods:




NameType
draggable( options ) Returns: jQuery
Creates new draggables on the nodeset supplied by the query.
draggable( "disable" ) Returns: jQuery
Temporarily disable the draggable functionality.
draggable( "enable" ) Returns: jQuery
Enable the draggable functionality.
draggable( "destroy" ) Returns: jQuery
Completely remove the draggable functionality.

NameType
Example:
Makes the div draggable.

$(".block").draggable();

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script src="http://dev.jquery.com/view/tags/ui/1.5b2/ui.base.js"></script>
  <script src="http://dev.jquery.com/view/tags/ui/1.5b2/ui.draggable.js"></script>
  <script src="http://dev.jquery.com/view/tags/ui/1.5b2/ui.draggable.ext.js"></script>

  <script>
  $(document).ready(function(){
    $(".block").draggable();
  });
  </script>
  <style>
  .block { 
    border: 2px solid #0090DF;
    background-color: #68BFEF;
    width: 150px; 
    height: 70px;
    margin: 10px; 
  }
  </style>
</head>
<body>
  <div class="block"></div>
</body>
</html>

NameType