js前端开发 需要的图片拖动

刚毕业做前端开发js要学到什么程度?|h5前端开发需要学什么软件下载?|一个前端开发需要考什么证?

html 代码

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
    <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
    <title>前端开发为什么要学js?js图片拖动</title>
    <script type=”text/javascript” src=”js/jquery.1.4.2-min.js”></script>
</head>
<body>
    <style>
        #img1 {
            position: absolute;
            cursor: move;
        }
    </style>
    <script>
        window.onload = function () {
            var oImg = document.getElementById(‘img1’);
            drag(oImg);
            function drag(obj) {
                obj.onmousedown = function (ev) {
                    var ev = ev || event;
                    var disX = ev.clientX – this.offsetLeft;
                    var disY = ev.clientY – this.offsetTop;
                    document.onmousemove = function (ev) {
                        var ev = ev || event;
                        obj.style.left = ev.clientX – disX + ‘px’;
                        obj.style.top = ev.clientY – disY + ‘px’;
                    }
                    document.onmouseup = function () {
                        document.onmousemove = document.onmouseup = null;
                    }
                    return false;
                }
            }
        }
    </script>
    <div class=”main”>
        <img id=”img1″ src=”http://sandbox.runjs.cn/uploads/rs/198/kn8pai72/index_29.jpg” />
    </div>
</body>
</html>

一个前端开发需要考什么证?|前端js开发工具|js前端开发框架

» 本文来自:前端开发者 » 《js前端开发 需要的图片拖动》
» 本文链接地址:https://www.rokub.com/3940.html
» 您也可以订阅本站:https://www.rokub.com
赞(0)
64K

评论 抢沙发

评论前必须登录!