jquery UI Draggable和Droppable 案例

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html>
<head><title>draggable</title>
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.3.custom.min.js"></script>
</head>
<body>
<div id="container" style="background-color:#ccc;width:500px;height:300px;">
    <div class="alert alert-dismissable alert-info dragsource">
    <p>aaaa</p>
    </div>
    <div class="alert alert-dismissable alert-info dragsource">
    <p>bbbb</p>
    </div>
    <div class="alert alert-dismissable alert-info dragsource">
    <p>cccc</p>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        $(".dragsource").draggable({
            revert: "invalid",
            cursor: "move", //移动时鼠标的位置
            cursorAt: { top: 56, left: 56 },
            snap: ".dragsource",//吸附到其他可托动元素
            containment: "parent",//限制拖放范围,亦可以用四元数组
            //axis: "y",//只可以沿着Y轴拖动
            start: function (event, ui) {
                //$(this).find("p").html("Starting");
            },
            stop: function (event, ui) {
                // $(this).find("p").html("stop");
            }
        });
        $("#container").droppable({
            //activeClass: "ui-state-hover",
            //hoverClass: "ui-state-active",//拖动时的样式
            activate: function (event, ui) {
                // $(this).find("p").html( "Drop here !" );
            },
            over: function (event, ui) {
                // $( this ).find( "p" ).html( "Oh, Yeah!" );
 
            },
            out: function (event, ui) {
                // $( this ).find( "p" ).html( "Don‘t leave me!" );
 
            },
            drop: function (event, ui) {
                //拖放
                // $(this).addClass("ui-state-highlight").find("p").html("Dropped!");
            }
        });
    })
    </script>

  

jquery UI Draggable和Droppable 案例,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。