{"id":741,"date":"2017-03-06T17:11:24","date_gmt":"2017-03-06T09:11:24","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=741"},"modified":"2017-03-06T16:31:18","modified_gmt":"2017-03-06T08:31:18","slug":"js%e5%ae%9e%e7%8e%b04%e4%b8%aa%e6%96%b9%e5%90%91%e6%bb%9a%e5%8a%a8%e7%9a%84%e7%90%83","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=741","title":{"rendered":"js\u5b9e\u73b04\u4e2a\u65b9\u5411\u6eda\u52a8\u7684\u7403"},"content":{"rendered":"<pre class=\"brush:html;toolbar:false\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=\"UTF-8\"&gt;\r\n        &lt;title&gt;\u524d\u7aefABC-qdabc.cn&lt;\/title&gt;\r\n        &lt;style&gt;\r\n            *{\r\n                margin: 0;\r\n                padding: 0;\r\n            }\r\n            #wrap{\r\n                width: 800px;\r\n                height: 500px;\r\n                border: 1px solid deeppink;\r\n                margin-left: 10px;\r\n                margin-top: 5px;\r\n                float: left;\r\n            }\r\n            #input1{\r\n                width: 80px;\r\n                margin: 5px auto 5px 10px;\r\n                font-size: 0;\r\n                float: left;\r\n            }\r\n            #div1{\r\n                width: 100px;\r\n                height: 100px;\r\n                background: hotpink;\r\n                position: absolute;\r\n                top: 20px;\r\n                left: 30px;\r\n                border-radius: 100px;\r\n                box-shadow: 0px 5px 5px rgba(0,0,0,.5);\r\n            }\r\n            input{\r\n                width: 100px;\r\n                height: 40px;\r\n                line-height: 40px;\r\n                text-align: center;\r\n                font-size: 18px;\r\n                display: block;\r\n                background: palegreen;\r\n                margin-bottom: 5px;\r\n            }\r\n        &lt;\/style&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;div id=\"wrap\"&gt;\r\n            &lt;div id=\"div1\"&gt;&lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n        &lt;div id=\"input1\"&gt;\r\n                &lt;input type=\"button\" value=\"\u5411\u5de6\" id=\"btn2\" \/&gt;\r\n                &lt;input type=\"button\" value=\"\u5411\u53f3\" id=\"btn1\"\/&gt;\r\n                &lt;input type=\"button\" value=\"\u5411\u4e0a\" id=\"btn3\" \/&gt;\r\n                &lt;input type=\"button\" value=\"\u5411\u4e0b\" id=\"btn4\"\/&gt;\r\n            &lt;\/div&gt;\r\n        &lt;script&gt;\r\n            var oBtn=document.getElementById('btn1');\r\n            var oDiv=document.getElementById('div1');\r\n            var oBtn2=document.getElementById('btn2');\r\n            var oBtn3=document.getElementById('btn3');\r\n            var oBtn4=document.getElementById('btn4');\r\n            oBtn4.onclick=function(){\r\n                move(oDiv,10,380,'0px 5px 5px rgba(0,0,0,.5)','top');\r\n            }\r\n            oBtn3.onclick=function(){\r\n                move(oDiv,-10,30,'0px -5px 5px rgba(0,0,0,.5)','top');\r\n            }\r\n            oBtn2.onclick=function(){\r\n                move(oDiv,-10,40,'-5px 5px 5px rgba(0,0,0,.5)','left');\r\n            }\r\n            oBtn.onclick=function(){\r\n                move(oDiv,10,680,'5px 5px 5px rgba(0,0,0,.5)','left');\r\n            }\r\n            \r\n            function move(obj,val,target,bs,dir){\r\n                obj.style.boxShadow=bs;\r\n                clearInterval(obj.timer);\r\n                obj.timer=setInterval(function(){\r\n                    var speed=parseInt(getStyle(obj,dir))+val;\r\n                    if(speed&gt;=target&amp;&amp;val&gt;0){\r\n                        speed=target;\r\n                    } \r\n                    if(speed&lt;=target&amp;&amp;val&lt;0){\r\n                        speed=target\r\n                    }\r\n                    obj.style[dir]=speed+'px';\r\n                    if(speed==target){\r\n                        clearInterval(obj.timer);\r\n                    }\r\n                },30);\r\n            }\r\n            \r\n            function getStyle(obj,sty){\r\n                return obj.currentStyle?obj.currentStyle[sty]:getComputedStyle(obj)[sty];\r\n            }\r\n        &lt;\/script&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=741\">js\u5b9e\u73b04\u4e2a\u65b9\u5411\u6eda\u52a8\u7684\u7403<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&#8221;UTF-8&#8243;&gt; &lt;title&gt;\u524d\u7aefABC-qdab [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":90,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/741"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=741"}],"version-history":[{"count":1,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/741\/revisions"}],"predecessor-version":[{"id":742,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/741\/revisions\/742"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/media\/90"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}