Solved

iQuery animation slide not working

Posted on 2013-01-25
3
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Kiran Paul VJ 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 34

Author Comment

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

works.

Thank you.
0
 
LVL 16

Expert Comment

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

kiranvj
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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).

751 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