Purpose: To achieve the movement of the Div box via a button
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <styletype= "Text/css">#bbb{Height:300px;width:300px;Background-color:AliceBlue;position:relative; } </style> <Scriptsrc=".. /jquery-3.2.1/jquery-3.2.1.js "></Script> <Scripttype= "Text/javascript"> $(function() { $("#left"). Click (function() { $("Div:not (: Animated)"). Animate ({left:"-=100" }, -); }); $("#right"). Click (function() { $("Div:not (: Animated)"). Animate ({right:"-=100" }, -); }); $("#up"). Click (function() { $("Div:not (: Animated)"). Animate ({top:"-=100" }, -); }); $("#down"). Click (function() { $("Div:not (: Animated)"). Animate ({bottom:"-=100" }, -); }); }) </Script> </Head> <Body> <ButtonID= "Left">Left</Button> <ButtonID= "Right">Right</Button> <ButtonID= "Up">Up</Button> <ButtonID= "Down">Down</Button> <DivID= "BBB"></Div> </Body></HTML>
Result: only static, but function to achieve
07.30 "jQuery"--2.1div box movement