1 |
torben |
2125 |
<!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.9.1.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 |
|
|
|
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 |
|
|
<div class="demo-description"> |
37 |
|
|
<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> |
38 |
|
|
<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> |
39 |
|
|
</div> |
40 |
|
|
</body> |
41 |
|
|
</html> |