zoukankan      html  css  js  c++  java
  • droppable

    easyui的droppable使得被声明的元素变为可放置元素,即该元素可做为容器,盛放被拖拽的元素

    <!DOCTYPE html>
    <html>
    <head>
    <title>jQuery Easy UI</title>
    <meta charset="UTF-8" />
    <script type="text/javascript" src="C:/Users/秋萍/Desktop/easyui/jquery-easyui-1.5.1/jquery.min.js"></script>
    <script type="text/javascript" src="C:/Users/秋萍/Desktop/easyui/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="C:/Users/秋萍/Desktop/easyui/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js" ></script>
    <link rel="stylesheet" type="text/css" href="C:/Users/秋萍/Desktop/easyui/jquery-easyui-1.5.1/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="C:/Users/秋萍/Desktop/easyui/jquery-easyui-1.5.1/themes/icon.css" />
    <script type="text/javascript">
        $(function(){
            $.fn.droppable.defaults.disabled=true;//设置默认为不可以放置元素
            $('#dd').droppable({
                accept : '#box',
                disabled : false,//设置容器可以放置元素
                onDragEnter : function(e,source){//被拖拽的元素到容器时 触发
                    $(this).css('background','blue');
                    console.log('----'+e);//e 当前对象
                    for(x in e){
                        console.log(x+'-------'+e[x]);
                    }
                    console.log('----'+source);// source 被拖拽的对象
                    for(x in source){
                        console.log(x+'-------'+source[x]);
                    }
                    //alert("enter");
                },
                onDragOver : function(e,source){//被拖拽的元素经过容器时 触发
                    $(this).css('background','#f00');
                    alert("over");
                },
                onDragLeave : function(e,source){//被拖拽的元素离开容器时 触发
                    $(this).css('background','#ff0');
                },
                onDrop : function(e,source){//被拖拽的元素放置在容器时 触发
                    $(this).css('background','#000');
                    console.log($("#dd").droppable("options"));//获得 对象的 option属性对象
                    //$("#dd").droppable("disable");//设置容器不可以放置元素
                    //$("#dd").droppable("enable");//设置容器可以放置元素
                }
            });
            $('#box').draggable({
            });
        });
    </script>
    </head>
    <body>
    <div id="dd" style="600px;height:400px;background:black"></div>
    <div id="box" style="100px;height:100px;background:#ccc;">
        <span id="pox">内容部分</span>
    </div>
    </body>
    </html>
  • 相关阅读:
    speechSynthesis 离线语音合成 浏览器自动播报
    提问的智慧
    实用工具
    《大数据时代》——思维导图
    数据分析技能提升十大建议
    vue根据权限生成动态路由及导航菜单
    vue中实现JavaScript桌面消息通知(push.js)
    vue中如何封装axios及如何使用
    启用多个服务器的webpack配置
    移动端input获取焦点弹出输入框时影响fixed布局的问题
  • 原文地址:https://www.cnblogs.com/m01qiuping/p/6486324.html
Copyright © 2011-2022 走看看