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

  • SEARCH
  • Home
  • 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 6595547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:57:14+00:00 2026-05-25T17:57:14+00:00

I have three buttons on the site and when you click each one, they

  • 0

I have three buttons on the site and when you click each one, they use .load to add different things to a DIV. The problem I’m having is whenever you click a button, it sends you back to the top of the page. I’ve tried using preventDefault() and return false but it didn’t work for me, I might have just placed it in the wrong spot.

You can see the problem at http://coralspringshigh.org/cshs/ , here’s the jQuery that I have now:

    if($(tabsId).length > 0){
            loadTab($(tabsId));
        }
        $(tabsId).click(function(){
            if($(this).hasClass(selected)){ return false; }
            $(tabsId).removeClass(selected);
            $(this).addClass(selected);
            $(containerId).hide();
                loadTab($(this));
            $(containerId).fadeIn();
            return false;
        });

    function loadTab(tabObj){
     if(!tabObj || !tabObj.length){ return; }
     $(containerId).addClass('loading');
     $(containerId).load(tabObj.attr('href'), function(){
          $(containerId).removeClass('loading');
          $(containerId).fadeIn('fast');
     });
    }

Thank you in advance.

  • 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-05-25T17:57:14+00:00Added an answer on May 25, 2026 at 5:57 pm

    Your Issue

    When you are loading the content, you are hiding the previous content, which is shortening your page. So, your page is not scrolling up, but your page is becoming shorter, and your browser is re-aligning to the new bottom of the page. This is what is causing the behavior you are seeing.

    The Solution(s)

    To solve this problem, there are a few things you can do. My recommendation is to load the content in the background, and display a loading overlay that goes over the old content. Then, when the new content is loaded, swap it out by hiding the old content after you show the new content. The user won’t see a difference since it will happen quickly, but you not get that ‘scroll’ effect.

    Another way to solve it is to use the jQuery .scrollTo() function to scroll to the new content after it is loaded, so that the content goes to the top of the page (or as high as the page can be).

    Addendum

    Your HTML is not completely valid. The <div> element cannot have an href attribute. Instead, wrap your text in an <a> tag to make it valid.

    <div class="classname"><a href="page.html" class="ajaxclicklink">Students</a></div>
    

    and from there, your code should do a

    event.preventDefault();
    event.stopPropagation();
    

    This will stop the default linking, and also allow the use of a browser that does not support javascript. It is a good practice (and more symatically correct, imo) to have full working links instead of just javascript faked links.

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

Sidebar

Related Questions

I have three radio buttons with same name and different values.When I click the
I have div which has three buttons as, <div id=buttons> <input id=preview class=ButtonStyle type=submit
I have one label field and three buttons with the name of red, yellow,
Lets say I have one row with three columns - some buttons on left
I have three buttons in a three column structure in a custom cell in
In my page I have three radio buttons and I want to checked the
I have a group of three radio buttons. Depending on which radio button is
I have three button named(titled) hello, nothing, heaven and one label (IBOutlet UIlabel lab).
I have a form with N textareas (each with a different name and id)
I need a solution to this problem: I have a django site that displays

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.