实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
AخA
 
1
<!doctype html>
2
<html lang="en">
3
<head>
4
  <meta charset="utf-8">
5
  <title>jQuery UI 拖动(Draggable) - 约束运动</title>
6
  <link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
7
  <script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
8
  <script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
9
  <link rel="stylesheet" href="jqueryui/style.css">
10
  <style>
11
  .draggable { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
12
  #draggable, #draggable2 { margin-bottom:20px; }
13
  #draggable { cursor: n-resize; }
14
  #draggable2 { cursor: e-resize; }
15
  #containment-wrapper { width: 95%; height:150px; border:2px solid #ccc; padding: 10px; }
16
  h3 { clear: left; }
17
  </style>
18
  <script>
19
  $(function() {
20
    $( "#draggable" ).draggable({ axis: "y" });
21
    $( "#draggable2" ).draggable({ axis: "x" });
22