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 5966811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:51:10+00:00 2026-05-22T19:51:10+00:00

I have a link on my page that when clicked uses .$get and then

  • 0

I have a link on my page that when clicked uses .$get and then append to load content into a div#top-main-content. After this content is loaded I want the page to scroll down to the content that was loaded into #top-main-content. How can I achieve this?

  $(document).ready(function()
                          {

                              $('a.newsflash1').click(function() 
                                {
$('html,body').animate({
                                    scrollTop: '+=' + $('#scrollTo').offset().top + 'px'
                                    }, 'fast');
                                    $('#top-main-content').empty();

                                    $.get('index.xml', function(c){

                                    $(c).find('news_story').each(function(){

                                        var $story = $(this); 
                                        var storyTitle = $story.find("story_title").text();
                                        var storyCompany = $story.find("story_company").text();
                                        var storyAuthor = $story.find("story_author").text();
                                        var storyYear = $story.find("story_date").attr("year");
                                        var storyMonth = $story.find("story_date").attr("month");
                                        var storyDay = $story.find("story_date").attr("day");
                                        var description = $story.find('story_content').text();

                                        var html = '<div class="story-content darkborder">';
                                        html += '<div class="story-contrast lightborder">';
                                        html += '<h3 class="story-title">' + storyTitle + '</h3>';
                                        html += '<div class="story-copyright">';
                                            html += '<p class="story-company">'+ storyCompany +'</p>';
                                            html += '<p class="story-author">'+ storyAuthor +'</p>';
                                            html += '<p class="story-date">'+ storyYear+'.'+storyMonth+'.'+storyDay +'</p>';
                                        html += '</div>';
                                        html += '<p class="story-body">' +  description + '</p>';
                                        html += '</div>';
                                        html += '</div>';


                                        $('#top-main-content').append($(html));

                                        window.location.hash = '#top-main-content';

                                    });
                                });
                            });
                        });

Okay I have figured it out with the below code :

$('html,body').animate({
scrollTop: '+=' + $('#scrollTo').offset().top + 'px'
}, 'fast');

I’ve also fixed my code above so that you can see how it works.

  • 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-22T19:51:11+00:00Added an answer on May 22, 2026 at 7:51 pm

    Try this:

    window.location.hash = '#top-main-content';
    

    Or try this scrollTo plugin

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

Sidebar

Related Questions

Basically I have a web page that has a div id=content and a div
I have a link on a page that pops up a new window, and
I have a subscription link on a page that the logged in users can
I have an absolute URL, and the URL that a link on that page
I have a Site Map link that opens up a Web Resource .htm page.
I have this line below that shows a link to go the next page
I would like to have a div which changes its content on the page
I want to make a link on a page that when clicked, would open
I have a page that uses window.print(); which is already printed in the source.
I have an area on a page that uses with overflow. In side that

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.