Javascript/Bootstrap scroll to section only after the page loads

This project was successfully completed by shailendra041090 for $10 USD in a day.

Get free quotes for a project like this
Project Budget
$10 - $30 USD
Completed In
1 day
Total Bids
Project Description

We have a website which uses jquery to scroll to a previously opened section when the user visits a page. It is using the bootstrap code below to get the previous section via a cookie and then scroll to it.

$(".collapse").on('[url removed, login to view]', function(e) {

var scrollToSection = $.cookie('scrollToSection');

if (scrollToSection != null && $("#" + scrollToSection).length) {

$('html, body').animate({

scrollTop: $('#' + scrollToSection).offset().top

}, 1000);



This works fine, but if the user expands a section after the page loads it will still scroll to the previous section. We want to fix this so that it only scrolls to the active section when the page first loads. If you are interested in the project let me know and I can walk you through the process to replicate this on our development site.

Completed by:

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online