• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

iQuery animation slide not working

I have 3 buttons each performing simple animations. The last button ( <button id="moveDiv" >Move Div</button>) is not working.

Question: How can I fix the code so that upon click on "Move Div" button, the div will swing to the right?

Thank you,


<!DOCTYPE html>

	<title>iQuery CSS sizing and positioning</title>
	<script type="text/javascript" src="jQuery/jquery-1.3.2.js"></script>
	<script type="text/javascript">
		//$("document").ready(function() {
		  	$(function() {
				$("#growRight").click(function() {
					$("#theDiv").animate({width: "500px"},1000);
				$("#bigText").click(function() {
					$("#theDiv").animate({fontSize: "24pt"}, 1000);
				$("#moveDiv").click(function() {
					$("#theDiv").animate({ left: "500" }, 1000, "swing");
	<style type="text/css">
		div#theDiv { 
			height: 180px;
			width: 250px;
			margin: 10px;
			padding: 20px;
			background: Lightblue;
			border: 2px solid black;
			offset: 250px;
			cursor: pointer;
		p, span {
			font-size: 18pt;
		button {margin: 2px;}
	  <p>Fading an Element</p>
	  <div id="theDiv">Animate Me</div>
	  <button id="growRight" >Grow Right</button>
	  <button id="bigText" >Big Text</button>
	  <button id="moveDiv" >Move Div</button>

Open in new window

Mike Eghtebas
Mike Eghtebas
  • 2
1 Solution
Kiran Paul VJComputer EngineerCommented:

left: "500px"

instead of left: "500"

also #moveDiv should be positioned relative or absolute for property left to work.

just try CSS

#moveDiv {
Mike EghtebasDatabase and Application DeveloperAuthor Commented:


Thank you.
Kiran Paul VJComputer EngineerCommented:
Good to know it helped. Thanks for the points and grade.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now