$(document).ready(function() {
$(".div1").click(function() {
$(".div2").stop().animate(...);
});
});
div1 and div2 are both divs in <div id="content">.
I want to click div1, then div2’s position will go to: top:0px; left:200px; which is relative to <div id="content" style="width:800px;margin:0 auto;">
How to write the animate part?
You can just pass an object to
.animate()withtopandleftproperties, like this:Make sure the element has a
relativeorabsoluteposition set here, whichever you’re going for, otherwisetopandleftwill have no effect.