handle.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI Draggable - Handles</title>
  6. <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
  7. <script src="../../jquery-1.10.2.js"></script>
  8. <script src="../../ui/jquery.ui.core.js"></script>
  9. <script src="../../ui/jquery.ui.widget.js"></script>
  10. <script src="../../ui/jquery.ui.mouse.js"></script>
  11. <script src="../../ui/jquery.ui.draggable.js"></script>
  12. <link rel="stylesheet" href="../demos.css">
  13. <style>
  14. #draggable, #draggable2 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
  15. #draggable p { cursor: move; }
  16. </style>
  17. <script>
  18. $(function() {
  19. $( "#draggable" ).draggable({ handle: "p" });
  20. $( "#draggable2" ).draggable({ cancel: "p.ui-widget-header" });
  21. $( "div, p" ).disableSelection();
  22. });
  23. </script>
  24. </head>
  25. <body>
  26. <div id="draggable" class="ui-widget-content">
  27. <p class="ui-widget-header">I can be dragged only by this handle</p>
  28. </div>
  29. <div id="draggable2" class="ui-widget-content">
  30. <p>You can drag me around&hellip;</p>
  31. <p class="ui-widget-header">&hellip;but you can't drag me by this handle.</p>
  32. </div>
  33. <div class="demo-description">
  34. <p>Allow dragging only when the cursor is over a specific part of the draggable. Use the <code>handle</code> option to specify the jQuery selector of an element (or group of elements) used to drag the object.</p>
  35. <p>Or prevent dragging when the cursor is over a specific element (or group of elements) within the draggable. Use the <code>cancel</code> option to specify a jQuery selector over which to "cancel" draggable functionality.</p>
  36. </div>
  37. </body>
  38. </html>