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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:15:59+00:00 2026-05-28T02:15:59+00:00

If I have a structure like: <div id=listofstuff> <div class=anitem> <span class=itemname>Item1</span> <span class=itemdescruption>AboutItem1</span>

  • 0

If I have a structure like:

<div id="listofstuff">
<div class="anitem">
   <span class="itemname">Item1</span>
   <span class="itemdescruption">AboutItem1</span>
</div>
<div class="anitem">
   <span class="itemname">Item2</span>
   <span class="itemdescruption">AboutItem2</span>
</div>
<div class="anitem">
   <span class="itemname">Item3</span>
   <span class="itemdescruption">AboutItem3</span>
</div>
</div>

Say I continue this pattern until item5… and I wanted to make it so that when the page loads, it would search for the div with itemname “Item5”, and scroll to it so that it is visible. Assume that the listofstuffdiv is sized small such that only 3 anitems are shown at any given time, but since overflow:auto exists, user can scroll.

I want to make it so that jquery can scroll to the item it found so it is visible without the user having to scroll down to item5;.

  • 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-28T02:16:00+00:00Added an answer on May 28, 2026 at 2:16 am

    See this fiddle: http://jsfiddle.net/pixelass/uaewc/2/

    You don’t need the scrollTo plugin for this..

    jQuery

    $(document).ready(function(){
        lastElementTop = $('#listofstuff .anitem:last-child').position().top ;
        scrollAmount = lastElementTop - 200 ;
    
    $('#listofstuff').animate({scrollTop: scrollAmount},1000);
    });
    

    CSS

    .anitem {
    height:100px;
    }
    
    #listofstuff {
    
    height:300px;
        overflow:auto;
    }
    

    with a little more action and variables http://jsfiddle.net/pixelass/uaewc/5/


    $(document).ready(function() {
        var wrapper = $('#listofstuff'),
        element = wrapper.find('.anitem'),
        lastElement = wrapper.find('.anitem:last-child'),
        lastElementTop = lastElement.position().top,
        elementsHeight = element.outerHeight(),
        scrollAmount = lastElementTop - 2 * elementsHeight;
    
        $('#listofstuff').animate({
            scrollTop: scrollAmount
        }, 1000, function() {
            lastElement.addClass('current-last');
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have html structure like this <div> <span class=ic> <span class=ic>12345</span> </span> </div> i
Ok, I have a structure like this: <div class=image> <img src=img1.jpg alt= /> </div>
Ok, so i have a HTML structure like this: <div class=content> <div id=a1 class=article>
I have a structure that looks like this: <div class=project_group> <table> <tr style=display:none> <td>...</td>
I have a HTML structure like follows <div id=answer-1> <a class=edit></a> </div> <div id=answer-2>
I have a DOM structure that looks like this: <div id=comment-1234 class=comment>...</div> <div id=comment-2391
I have a html structure like this: <div class=one> <div id=two> <h2>Any</h2> <h4>Any</h4> </div>
Suppose I have a huge list of elements with a structure like: <div class=item>
I have a div structure like the bottom: <div class=body-content> <div class=col-middle> </div> </div>
I am trying to use jQuery(#element-id).parent().addClass('some-class'); I have a structure something like this: <div

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.