Animation Effect Jquery: How to animate Div or Element using Jquery

Today I am going to show you code on how to move div or how to create animation effect in Jquery. 

1) Move elements Right and Left

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Jqury Animation Tutorial by Darpan Pathak</title>

<style type="text/css">
	
.car1{width:300px; float:left; height:200px; background:url(http://www.alychitech.com/wp-content/uploads/2013/08/newcar.png) no-repeat;position:relative;}
	
</style>



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script> 
$(document).ready(function(){
  $("#btngoright").click(function(){
    $("#car1").animate({left: '+=350', bottom: '+=0'}, 2000);
  });
  
  $("#btngoleft").click(function(){
    $("#car1").animate({left: '-=350', bottom: '+=0'}, 2000);
  });
  
});
</script> 

</head>

<body>

<button id="btngoright"> >> Go Right </button>

<button id="btngoleft">  Come back Left </button> <br /><br />

<div id="car1" class="car1"></div>

</body>
</html>


Demo: Move elements Right and Left

2) Move elements Up and Down

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Jqury Animation Tutorial by Darpan Pathak</title>

<style type="text/css">
	
.baloon{width:200px; height:200px; background:url(https://alychidesigns/wp-content/uploads/2013/08/baloons.png) no-repeat;position:relative; margin-left:180px;}
	
</style>



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script> 
$(document).ready(function(){
  $("#btngoup").click(function(){
    $("#baloon").animate({bottom: '+=200'}, 2000);
  });
  
  $("#btngodown").click(function(){
    $("#baloon").animate({bottom: '-=200'}, 2000);
  });
  
});
</script> 

</head>

<body>

<div style="float:left;">
<button id="btngoup"> >> Go Up </button> <br />
<button id="btngodown"> >> Come back down </button>
</div>

<div id="baloon" class="baloon"></div>

</body>
</html>


Demo: Move elements Up and Down


Aly Chiman

Aly Chiman is a Blogger & Reporter at AlyChiTech.com which covers a wide variety of topics from local news from digital world fashion and beauty . AlyChiTech covers the top notch content from the around the world covering a wide variety of topics. Aly is currently studying BS Mass Communication at University.