Search code examples
jqueryslidetoggleeasing

Adding an ease to a simple slide / jquery


i finally found the perfect, simple jquery code for my new page:

<script type="text/javascript">
 $(document).ready(function(){

        $(".slidingDiv").hide();
        $(".show_hide").show();

    $('.show_hide').click(function(){
    $(".slidingDiv").slideToggle();
    });

});
</script>

I would like to add the easing function and time, like in this code:

  $('#mypage-info').slideToggle('2000', "easeOutBounce", function () {
      // Animation complete.
   });
});

My guess would be:

<script type="text/javascript">
 $(document).ready(function(){

        $(".slidingDiv").hide();
        $(".show_hide").show();

    $('.show_hide').click(function(){
    $(".slidingDiv")..slideToggle('2000', "easeOutBounce", function () {

    });

});
</script>

but i get an error...


Solution

  • Just remove the double . you have. You have a syntax error. Change:

    $(".slidingDiv")..slideToggle('2000', "easeOutBounce", function () {
    

    to this:

    $(".slidingDiv").slideToggle('2000', "easeOutBounce", function () {