Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:38:33+00:00 2026-06-17T07:38:33+00:00

I am using Ariel Flesler’s scrollTo plugin with bootstrap. It looks really simple but

  • 0

I am using Ariel Flesler’s scrollTo plugin with bootstrap. It looks really simple but I can’t get it to work. I want to click the buttons and it will scroll smoothly to the respective ids. Here’s an example of one button.

Here’s the html:

<a class="btn btn-primary" href="#faqs"></i>FAQS</a>

<div class="id="faqs">



<script src="js/jquery.scrollTo-1.4.3.1-min.js"></script>

Qn. 1 What should the jQuery be so that all my buttons work?

Qn. 2 Incidentally, I stole from twitter bootstrap’s website “application.js” without understanding what they mean but to just hack together to make my website work. Could you explain what these code mean?

//Is this bit of code the convention to add to the start of every jQuery doc?
!function ($) {
$(function(){
var $window = $(window)

//What does this do?
$('[href^=#]').click(function (e) {
  e.preventDefault()
})


//This code scrolls smoothly to top, however it only works when the code below is present. Why?
$("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
})


// This is the weird bit of code I don't understand. Without this, my scrollTop doesn't work. Could this bit of code also interfere with scrollTo's plugin? I assume it will...
$('.download-btn .btn').on('click', function () {

  var css = $("#components.download input:checked")
        .map(function () { return this.value })
        .toArray()
    , js = $("#plugins.download input:checked")
        .map(function () { return this.value })
        .toArray()
    , vars = {}
    , img = ['glyphicons-halflings.png', 'glyphicons-halflings-white.png']

Thanks for answering all my questions, appreciate it a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:38:34+00:00Added an answer on June 17, 2026 at 7:38 am

    See this:

    //Is this bit of code the convention to add to the start of every jQuery doc?
    !function ($) {
    $(function(){  //<--------------this is where jQuery starts working 'document ready function'
    var $window = $(window)
    

    and this:

    //What does this do?
    $('[href^=#]').click(function (e) {
      e.preventDefault();
    });
    

    the above script .preventDefault() is making sure that any <a> tag with attribute of href="#" when clicked page won’t jump up at the top, this is same as return false;

    and the below code:

    //This code scrolls smoothly to top, however it only works 
    //when the code below is present. Why?
    $("a[href='#top']").click(function() {
      $("html, body").animate({ scrollTop: 0 }, "slow");
      return false;
    });
    

    Yes this will work because it is selecting the <a> tag which has the href='#top' attribute here, when this gets clicked then the html, body will scroll to the top of the document position of 0. However this will work only for this link $("a[href='#top']")

    As you didnot mentioned full code but this wont do any harm if you want to scroll to specific div. you can modify the $("a[href='#top']").click(function() { or $('[href^=#]').click(function (e) { code to get all link working.

    you can tryout this script:

     $('[href^=#]').click(function (e) {
         e.preventDefault();
         var div = $(this).attr('href');
         $("html, body").animate({
             scrollTop: $(div).position().top
           }, "slow");
     });
    

    checkout in fiddle here: http://jsfiddle.net/Ja6DN/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Ariel Flesler's awesome scrollto plugin . But I want to determine when
I am using Ariel Flesler's ScrollTo jQuery plugin. Everything is great except when scrolling,
I'm currently using Ariel Flesler's scrollTo plugin for jQuery: http://flesler.blogspot.co.uk/2007/10/jqueryscrollto.html Example of it in
I'm working on a project and using Ariel Flesler's jquery.scrollTo.js & jquery.localScroll.js ... I
I am using Ariel Flesler's ScrollTo script on this page . I have two
I am trying to get the scrollTo jquery work. Tried various tutorias/methods but none
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Im trying to setup my rails server on OSX 10.8 but I can't get
I'm using Ariel Faigon's sort library, found here: http://www.yendor.com/programming/sort/ I was able to get
I'm using Ariel Flesler's serialScroll script and would like to add a class to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.