案例:jQuery UI案例     状态:可编辑再运行    进入竖版
 运行结果 
AخA
 
1
<!doctype html>
2
<html lang="en">
3
<head>
4
  <meta charset="utf-8">
5
  <title>jQuery UI 放置(Droppable) - 购物车演示</title>
6
  <link rel="stylesheet" href="/css/jqu1.10.4/jquery-ui.min.css">
7
  <script src="/js/jqu/jquery.min1.10.2.js"></script>
8
  <script src="/js/jqu/jquery-ui.min1.10.4.js"></script>
9
  <link rel="stylesheet" href="jqueryui/style.css">
10
  <style>
11
  h1 { padding: .2em; margin: 0; }
12
  #products { float:left; width: 500px; margin-right: 2em; }
13
  #cart { width: 200px; float: left; margin-top: 1em; }
14
  /* 定义列表样式,以便最大化 droppable */
15
  #cart ol { margin: 0; padding: 1em 0 1em 3em; }
16
  </style>
17
  <script>
18
  $(function() {
19
    $( "#catalog" ).accordion();
20
    $( "#catalog li" ).draggable({
21
      appendTo: "body",
22
      helper: "clone"
23
    });
24
    $( "#cart ol" ).droppable({
25
      activeClass: "ui-state-default",
26
      hoverClass: "ui-state-hover",
27
      accept: ":not(.ui-sortable-helper)",
28
      drop: function( event, ui ) {
29
        $( this ).find( ".placeholder" ).remove();
30
        $( "<li></li>" ).text( ui.draggable.text() ).appendTo( this );
31
      }
32
    }).sortable({
33
      items: "li:not(.placeholder)",
34
      sort: function() {
35
        // 获取由 droppable 与 sortable 交互而加入的条目
36
        // 使用 connectWithSortable 可以解决这个问题,但不允许您自定义 active/hoverClass 选项
37
        $( this ).removeClass( "ui-state-default" );
38
      }
39
    });
40
  });
41
  </script>
42
</head>
43
<body>
44
 
45
<div id="products">
46
  <h1 class="ui-widget-header">产品</h1>
47
  <div id="catalog">
48
    <h2><a href="#">T-Shirts</a></h2>