Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery SlideDown

Featured Replies

Hello Friends.

 

I'm playing around with jQuery cause I believe it is time I started learning it :)

 

Here is my code:

 

<script type="text/javascript">
       var jq = jQuery.noConflict();

       jq(document).ready(function () {

           jq('#feature').slideDown(6000);

       });

   </script>

 

I have an empty div with id feature, with a fixed width and height and a background image.

 

As the page loads, I want that particular div to slide down ! but I can't get it to work with jQuery. I have linked jQuery in my html.

 

I would greatly appreciate any help.

 

Thank You.

Try this instead ...

 

<script type="text/javascript">
       jQuery.noConflict();

       jQuery(function() {

           jQuery('#feature').slideDown(6000);

       });

   </script>

  • Author

Thanks for the reply Lee.

 

I just tried as you suggested, it didn't work. No slide down animation :(

 

How does one debug jQuery ?

  • Author

That isn't really what I want Faevilangel.

 

Mine is just a simple box div. I want it to slowly show as the page loads.

Simple slide down function i created

 

 

<script type="text/javascript">
function slide_down(id){
if($("#" + id).is(":hidden")){
$("#" + id).slideDown(500);
}
}

window.onload = slide_down("DivID");
</script>

 

The code above will slide whatever div u want it to on page load

  • Author

This is really getting me angry now ! nothing seems to work !!

 

<!DOCTYPE html>
<html>

<head>
<title>Playing with jQuery</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="jquery-1.5.1.min.js"></script>
</head>

<body>
<script type="text/javascript">

	function slide_down(id){
		if($("#" + id).is(":hidden")){
		$("#" + id).slideDown(500);
		}
	}

	window.onload = slide_down("feature");
</script>

<div id="feature">
	<p>Hello World.</p>
</div>
</body>

</html>

 

Please help :(

Try this:

 

<!DOCTYPE html>
<html>

<head>
       <title>Playing with jQuery</title>
       <link rel="stylesheet" type="text/css" href="styles.css" />
       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
</head>

<body>
       <script type="text/javascript">

$(function() {
$('#feature').hide();
$('#feature').slideDown('slow');
});
       </script>

       <div id="feature">
               <p>Hello World.</p>
       </div>
</body>

</html>

 

Or if you want to get a bit more technical, change the jQuery to:

 

$(function() {
$('#feature').hide();
});

$(document).ready(function() {
$('#feature').slideDown('slow');
});

 

Which would mean that the #feature div wouldn't slide until the page has fully loaded.

Edited by Spitfire

This is simply done using the animate function:

 

What i did was create a div called 'empty div' and positioned it relative. Then i positioned an image inside that using absolute positioning.

 

The HTML:

<div id="empty_div">

 <img src="images/img1.jpg" height="336" width="500" alt="" />

</div>

 

The CSS:

 

 #empty_div {

position: relative;
height: 400px;
width: 600px;
background-color: #f00;

}

#empty_div img {

	position: absolute;
top: 20px; left: 50px;

}

 

The jQuery:

 

<script type="text/javascript">

$(document).ready(function() {

$('#empty_div').delay(2000).animate({ top : 400}, 'slow');
});


</script>

 

Also i placed a delay on it so you can see it happen but just remove that and it will fire as soon as the page loads!

Edited by neilp

I always start small and build up, so you don't write a whole lot of code and it doesn't work. Usually I start with

 

$(".whatever").click(function(){

alert("hello");

});

 

once I know that this works, I start writing more code inside the function. Otherwise you are going to cause yourself a headache trying to figure out where the error is. Also Firebug is great for telling you when there is a javascript error :)

Edited by mrchristoph

  • Author
Also Firebug is great for telling you when there is a javascript error :)

 

Do you know of a video that shows you how to use Firebug to debug jQuery ?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.