Reputation: 11
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
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
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