jump to navigation

Animated Hide and Slide Toggle Content into View with JQuery October 9, 2011

Posted by Tournas Dimitrios in JQuery.

Here’s a simple code-snippet on how to show/ hide a div using jQuery. First we include the Google jQuery library, the next steps are simple :

  • Embed the jquery library into your HTML document ( preferably via CDN) .
  • setup a click event- listener which is triggered when a users clicks on the  object that has been assigned an click-event (via jquery) .
  • run jquery’s  “slidedown()” function . Simple as that ….. .

You’ll also notice that an “if-statement” is handling the “toggle” status  .

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
//trigger the function when DOM is ready
$(document).ready(function() {
$(".toggle").click(function() {
if ($(this).next().is(":hidden")) {


Live demo  and go to “view source mode ” with your browser to copy the whole code .



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s