The icon linear regression moves diagonally to the specified position _jquery

Source: Internet
Author: User
The icon moves diagonally and looks at the code.
Copy Code code as follows:

<! DOCTYPE HTML >
<title> icon Linear regression moved to the specified position </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<body style= "FONT-SIZE:13PX;" >
<div>
<div style= "margin:30px 0 30px 0;" >

<div style= "margin:50px 0 0 500px;" ><b id= "B" >B</b></div>
<div style= "margin:80px 0 0 300px;" ><b id= "D" >D</b></div>
</div>
<div>
<button name= "Move" >move</button>
<button name= "Reset" >reset</button>
</div>
</div>
<!--OK icon is set to hide floating-->
<div id= "OK" style= "display:none; Position:absolute; width:16px; Font-color:white; background-color:red; " >OK</div>

<script type= "Text/javascript" src= "Http://jt.875.cn/js/jquery.js" ></script>
<script type= "Text/javascript" >

var PB = {left: $ (' #b '). Position (). Left + $ ("#b"). Width (), Top: $ ("#b"). Position (). top};//b Point Position

var PD = {left: $ (' #d '). Position (). Left + $ ("#d"). Width (), Top: $ ("#d"). Position (). top};//d Point Position
$ ("#ok"). CSS ({left:pd.left, top:pd.top});//initial set OK at D Point

$ ("Button[name=move]"). Click (function () {//Click the Move button to start moving point B from D Point
$ ("#ok"). FadeIn (). Animate ({
Left:pb.left,
Top:pb.top
1000,function () {//1 seconds to complete the animation, you can set the animation speed, finished hiding
$ ("#ok"). Fadeout ()
});

});

$ ("Button[name=reset]"). Click (function () {//Click the Reset button to return to the original state
$ ("#ok"). Hide (). css ({left:pd.left, top:pd.top});
});
</script>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.