Thursday, September 19, 2013

Example jQuery slideToggle

The simple example playing with jquery slideToggle().

<script>
$(function(){
   $('.toggle').click(function(){
       var el = $(this).attr('rel');
       $(el).slideToggle();
   }); 
});
</script>

<button class="stoggle" rel="#hideMe">Click me</button>
<br />
<div id="hideMe" style="background: #ffffd0; display: none; height: 100px; text-align: center; width: 200px;">
I'm the hidden element
</div>

Demo: or toggle the element above:

By adding "rel" attribute, we can toggle specific elements.

No comments :

Post a Comment