PeterP
PeterP

Reputation: 71

Positioning in javascript animation

Lets say i have two divs in my code:

div1 - position(100,100)

div2 - position(100,200)

I am doing a javascript animation and I am wondering if there is any way to give them the same target position on the screen without giving them two different positions?

Ask if you want more information! Thanks

Upvotes: 0

Views: 94

Answers (1)

mainguy
mainguy

Reputation: 8331

Not quiet sure if I understand your question. Something like this? http://plnkr.co/edit/WKXV5amtwrQLefidmuAk?p=preview

$(document).ready(function () {
 $('.movediv').animate({
   top:'400',
   left:'400'
 },5000,function(){
 });
});

the CSS:

div1{
 width:100px;
 height:100px;
 background-color:red;
 position: absolute;
 top:100px;
 left:100px;
}

.div2{
  width:100px;
  height:100px;
  background-color:blue;
  position: absolute;
  top:100px;
  left:200px;
 }

and the HTML:

<body>
  <div class="movediv div1"></div> 
  <div class="movediv div2"></div> 
</body>

Upvotes: 1

Related Questions