Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jQuery Close Slide up

Posted on 2013-06-24
6
Medium Priority
?
367 Views
Last Modified: 2013-06-24
Hello,

Below is my code and I can not make it slide up when I click the #close image.

Can you please help me out.

Thanks,
Matt

<script type="text/javascript">
	$(document).ready(function(){
		$('.hidden').slideDown(450,function(){
			$('.rifle').animate({left:'0px'},250,function(){
				$('.name').animate({left:'0px'},150,function(){
					$('.instock').animate({left:'0px'},150,function(){
						$('.arrows').animate({left:'0px'},150,function(){
							$('.buynow').animate({left:'0px'},150,function(){
								$('.close').animate({left:'0px'},150,function(){
								});
							});
						});
					});
				});
			});
		});
	 });
	$('#close').click(function() {
		$('.hidden').slideUp(100, function() {
			// Animation complete.
		});
	});
</script>

Open in new window

0
Comment
Question by:movieprodw
  • 3
  • 3
6 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39272420
Where is the HTML part of your code.
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39272437
<!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=UTF-8" />
<title>Banner Test</title>
<style type="text/css">
<!--
.hidden{
	width:950px;
	height:120px;
	display:none;
	margin:0px auto;
	background-color: #333;
	position:relative;
	background-image: url(media/bannerflyin/banner-flyin-background.png);
	background-repeat: no-repeat;
	background-position: left top;
}
.rifle {
      position:absolute;
      left:-2000px;
      width:950px;
      height:120px;
}
.name {
      position:absolute;
      left:-2000px;
      width:950px;
      height:120px;
}
.instock {
      position:absolute;
      right:-2000px;
      width:950px;
      height:120px;
}
.arrows {
      position:absolute;
      left:-2000px;
      width:950px;
      height:120px;
}
.buynow {
      position:absolute;
      left:2000px;
      width:950px;
      height:120px;
}
.close {
	position:absolute;
	left:2000px;
	margin-left:895px;
	cursor:pointer
}
-->
</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('.hidden').slideDown(450,function(){
			$('.rifle').animate({left:'0px'},250,function(){
				$('.name').animate({left:'0px'},150,function(){
					$('.instock').animate({left:'0px'},150,function(){
						$('.arrows').animate({left:'0px'},150,function(){
							$('.buynow').animate({left:'0px'},150,function(){
								$('.close').animate({left:'0px'},150,function(){
								});
							});
						});
					});
				});
			});
		});
	 });
	$('#close').click(function() {
		$('.hidden').slideUp(100, function() {
			// Animation complete.
		});
	});
</script>

</head>

<body>
<br />
<br />
<div class="hidden">
<img class="instock" src="media/bannerflyin/banner-flyin-instock.png" width="950" height="120" alt="In Stock Now"  />
<img class="rifle" src="media/bannerflyin/banner-flyin-v5300-rifle.png" width="950" height="120" alt="rifle" />
<img class="name" src="media/bannerflyin/banner-flyin-v5300-logo.png" width="950" height="120" alt="rifle name" />
<img class="buynow" src="media/bannerflyin/banner-flyin-buynow.png" width="950" height="120" alt="Buy Now" />
<img class="arrows" src="media/bannerflyin/banner-flyin-arrows.png" width="950" height="120" alt="Arrows" />
<img class="close" id="close" src="media/bannerflyin/banner-flyin-close.png" width="51" height="44" alt="close" />
</div>
</body>
</html>

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39272461
Code as is works fine for me.
http://jsfiddle.net/aTRg7/7/
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:movieprodw
ID: 39272483
Weird, try it here, same code.

http://tinyurl.com/mmo76wf
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39272537
Place the close function inside the document.ready, you are trying to initiate it before the element has been created.
0
 
LVL 1

Author Closing Comment

by:movieprodw
ID: 39272565
Perfect!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

879 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