Pranav Ballaney
Pranav Ballaney

Reputation: 305

How to show/hide a div animatedly?

It is a dumb question, but I can't figure it out..

I want to show the div smoothly (slide down) when a link is clicked and hide it (slide up) when any other part of the page is click or the page is scrolled.

Upvotes: 1

Views: 106

Answers (2)

Akhil Sekharan
Akhil Sekharan

Reputation: 12683

Use slideToggle, easier for you:

JSBIN Demo

Slide Toggle

Upvotes: 0

antyrat
antyrat

Reputation: 27765

If you can use jQuery, you can work with .slideDown('slow') method for example.

Usage:

$( 'a#myLink' ).click( function() {
    $( '#myDiv' ).slideDown( 'fast' );
});

See jsFiddle demo.

Upvotes: 1

Related Questions