Mueedullah K.
Mueedullah K.

Reputation: 11

Scroll down window when toggle open

Hi I am working on a site where I have created "Toggle section" under the footer, but the problem is when the toggle opens the window does not scroll to the that toggled section that's why peoples can't see it. What I want is when the toggle open window should scroll to that section automatically when click toggle button to open it.

Here is the Js code that I have been using;

<script>
jQuery(document).ready(function(){
    jQuery('#hideshow').live('click', function(event) {        
         jQuery('#ticket-content').toggle('show');
    });
});
    </script>

And the website is here; Click here for website

Hope to have any help soon.

Thanks in advance.

Upvotes: 2

Views: 1394

Answers (2)

Manish Jangir
Manish Jangir

Reputation: 5437

Try this. I might help you.

jQuery(document).ready(function(){
    jQuery('#hideshow').live('click', function(event) {        
         jQuery('#ticket-content').toggle('show',function() {
            jQuery('html, body').animate({
                scrollTop: jQuery(this).offset().top
            }, 2000);

         });
    });
});

Upvotes: 1

Trevor
Trevor

Reputation: 16116

Try:

jQuery(document).ready(function(){
    jQuery('#hideshow').live('click', function(event) {        
         jQuery('#ticket-content').toggle(function(){
             jQuery('html, body').animate({
                 scrollTop: jQuery(this).offset().top
             }, 2000);
         });
     });
});

Upvotes: 0

Related Questions