1 | <!doctype html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <title>jQuery UI Draggable - Handles</title>
|
---|
5 | <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
|
---|
6 | <script type="text/javascript" src="../../jquery-1.4.1.js"></script>
|
---|
7 | <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
|
---|
8 | <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
|
---|
9 | <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script>
|
---|
10 | <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
|
---|
11 | <link type="text/css" href="../demos.css" rel="stylesheet" />
|
---|
12 | <style type="text/css">
|
---|
13 | #draggable, #draggable2 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
|
---|
14 | #draggable p { cursor: move; }
|
---|
15 | </style>
|
---|
16 | <script type="text/javascript">
|
---|
17 | $(function() {
|
---|
18 | $("#draggable").draggable({ handle: 'p' });
|
---|
19 | $("#draggable2").draggable({ cancel: "p.ui-widget-header" });
|
---|
20 | $("div, p").disableSelection();
|
---|
21 | });
|
---|
22 | </script>
|
---|
23 | </head>
|
---|
24 | <body>
|
---|
25 | <div class="demo">
|
---|
26 |
|
---|
27 | <div id="draggable" class="ui-widget-content">
|
---|
28 | <p class="ui-widget-header">I can be dragged only by this handle</p>
|
---|
29 | </div>
|
---|
30 |
|
---|
31 | <div id="draggable2" class="ui-widget-content">
|
---|
32 | <p>You can drag me around…</p>
|
---|
33 | <p class="ui-widget-header">…but you can't drag me by this handle.</p>
|
---|
34 | </div>
|
---|
35 |
|
---|
36 | <!-- ADD CANCEL DEMO -->
|
---|
37 |
|
---|
38 | </div><!-- End demo -->
|
---|
39 |
|
---|
40 | <div class="demo-description">
|
---|
41 |
|
---|
42 | <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>
|
---|
43 | <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>
|
---|
44 |
|
---|
45 | </div><!-- End demo-description -->
|
---|
46 | </body>
|
---|
47 | </html>
|
---|