1
|
1 |
<!DOCTYPE html> |
|
2 |
<html lang="en"> |
|
3 |
<head> |
|
4 |
<meta charset="UTF-8" /> |
|
5 |
<title>jQuery UI Draggable - Handles</title> |
|
6 |
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> |
|
7 |
<script type="text/javascript" src="../../jquery-1.4.2.js"></script> |
|
8 |
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> |
|
9 |
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> |
|
10 |
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> |
|
11 |
<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> |
|
12 |
<link type="text/css" href="../demos.css" rel="stylesheet" /> |
|
13 |
<style type="text/css"> |
|
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 type="text/javascript"> |
|
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 class="demo"> |
|
27 |
|
|
28 |
<div id="draggable" class="ui-widget-content"> |
|
29 |
<p class="ui-widget-header">I can be dragged only by this handle</p> |
|
30 |
</div> |
|
31 |
|
|
32 |
<div id="draggable2" class="ui-widget-content"> |
|
33 |
<p>You can drag me around…</p> |
|
34 |
<p class="ui-widget-header">…but you can't drag me by this handle.</p> |
|
35 |
</div> |
|
36 |
|
|
37 |
<!-- ADD CANCEL DEMO --> |
|
38 |
|
|
39 |
</div><!-- End demo --> |
|
40 |
|
|
41 |
<div class="demo-description"> |
|
42 |
|
|
43 |
<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> |
|
44 |
<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> |
|
45 |
|
|
46 |
</div><!-- End demo-description --> |
|
47 |
</body> |
|
48 |
</html> |