Requirements:
- page contains two HTML elements: a button, a small square
- Animation requirements: Click the button, the small square from the page coordinates 300,300, accelerate the move to 0,0
Relevant knowledge points:
- jquery Animation Method Animate
- Setting of the easing parameter
<!DOCTYPE HTML><HTMLLang= "zh"> <Head> <MetaCharSet= "Utf-8"> <title>Implement page element Acceleration animation effect</title> <styletype= "Text/css">. BTN{Border:1px solid #fff;Border-radius:4px;Background-color:#5cb85c;width:60px;Height:30px;Line-height:30px;text-align:Center;Color:#fff;cursor:Pointer; }. Btn:hover{Background-color:#449D44; }. Ball{position:Absolute; Left:10px;Top:60px;Background-color:#337AB7;width:50px;Height:50px;Border-radius:50px; } </style> <Scripttype= "Text/javascript"src= "Jquery-1.11.0.js"></Script> <Scripttype= "Text/javascript"src= "Jquery.easing.1.3.js"></Script> <Scripttype= "Text/javascript"> $(function() { var$div= $('. BTN'), $ball= $('. Ball'); $div. On ('Click', function() {$ball. Animate ({left:'200px', Top:'200px'}, 'Slow', 'jswing'); }) }); </Script> </Head> <Body> <Divclass= "BTN">Begin</Div> <Divclass= "Ball"></Div> </Body></HTML>
[jquery Programming Challenge]001: Implement page element Acceleration animation effect