Solved

iQuery animation slide not working

Posted on 2013-01-25
3
299 Views
Last Modified: 2013-01-26
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,

Mike
===========


<!DOCTYPE html>
  <html>
    <head>

	<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");
				});
			});
		//});
	</script>
	<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;}
	</style>
	</head>
	<body>
	  <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>
	</body>
</html>

Open in new window

0
Comment
Question by:Mike Eghtebas
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
kiranvj earned 500 total points
ID: 38821649
Try

left: "500px"

instead of left: "500"

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


just try CSS

#moveDiv {
 position:relative;
}
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 38821896
#theDiv{
 position:relative;
}

works.

Thank you.
0
 
LVL 16

Expert Comment

by:kiranvj
ID: 38821991
Good to know it helped. Thanks for the points and grade.

kiranvj
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i apply an assert arrayEqual function ? 2 26
Joomla 2.5 shopping cart 7 23
CSS: Making responsive table look nicer 7 26
jQuery for Each 12 19
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question