• jQuery拖到效果


      <style type="text/css">
            img
            {
                100px;
                height: 100px;
            }
            #mydiv
            {
                500px;
                height: 300px;
                border: solid 1px red;
            }
            #mydiv2
            {
                500px;
                height: 300px;
                border: solid 1px red;
            }
        </style>
        <script src="js/Jquery1.7.js" type="text/javascript"></script>
        <script src="js/jquery.ui.core.js" type="text/javascript"></script>
        <script src="js/jquery.ui.widget.js" type="text/javascript"></script>
        <script src="js/jquery.ui.mouse.js" type="text/javascript"></script>
        <script src="js/jquery.ui.draggable.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $('img').draggable({
                    //axis:'y'//规定只能沿y轴拖动
                    //containment: '#mydiv' //规定拖动的区域
                    //containment: 'parent' //父容器的另一种写法
                    //containment: '#mydiv2' //规定的拖动区域可以不是元素的父容器
                    //grid:[50,50]
                    opacity: 0.3, //设置拖动时的透明度
                    //revert: true,
                    start: function () {
                        $('#mydiv2').text('开始移动了');
                    },
                    stop: function () {
                        $('#mydiv2').text('停了');
                    },
                    drag: function () {
                        //$('#mydiv2').text('一直在努力');
                        $('#mydiv2').text($('img').offset().left + "," + $('img').offset().top);
                    }
                });
                //设置一个元素的距离浏览器左边缘和上边缘的距离(横坐标和纵坐标)
                $('#Button1').click(function () {
                    $('img').offset({
                        left: 200,
                        top: 200
                    });
                })
            })
        </script>
    </head>
    <body>
        <div id="mydiv">
            <img src="images/2.jpg" /></div>
        <div id="mydiv2">
            <input id="Button1" type="button" value="button" />
        </div>
    </body>

  • 相关阅读:
    ubuntu 16.0.5 修改网卡为固定IP
    Ubuntu PostgreSQL安装和配置
    NPOI 1.2.1版本替换为2.4.0版本实体类变更
    C# 之 Math取整
    解决github 下载过慢的问题
    优伦自动语言话务员设置
    python3学习笔记 列表
    【postgresql】role "root" does not exist 解决办法
    Eclipse使用的小技巧
    Servlet
  • 原文地址:https://www.cnblogs.com/qiqiBoKe/p/3092061.html
Copyright © 2020-2023  润新知