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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:25:32+00:00 2026-05-15T13:25:32+00:00

I came across great sites which had a cool feature, which I’ll try to

  • 0

I came across great sites which had a cool feature, which I’ll try to explain here.

I tried to study the .js sources, but as I’m a newbie I couldn’t decipher the minified versions. 🙁

Let’s say I have the following markup:

<ul id="posts">

<li id="photo"> Lorem ipsum </li>

<ii id="quote"> Lorem ipsum dolor </li>

</ul>

<div id="logo">My Logo</div>

What I want to do is: when user enters the li#photo area, jQuery would change the #navigator background color to, say, blue. If the user keeps scrolling down he would enter the li#quote, and when he enters the area, jQuery would change #navigator bg color to red.

When I say “enter the area”, I mean by scrolling and not by mouse hovering.

There’s a Tumblr theme that kind of does what I’m trying to explain:

http://www.figueric.com/ (scroll down and see the navigator on the right)

The only thing I can come up is to use the .addclass feature, but I don’t know where to start, specially when it comes to recognizing that the user is viewing the li#photo area, for example.

Can you guys give me some light here?

  • 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-15T13:25:33+00:00Added an answer on May 15, 2026 at 1:25 pm

    jQuery has a scroll() event you can use when scrolling. You just need to get the position of the child elements and see if they are in the current view.

    Here’s an example that you can test: http://jsfiddle.net/BKnzr/1/

    CSS

    html,body {
        padding:0;
        margin:0;
        clip: auto;
        overflow: hidden;
    }
    
    #navigator {
        text-align: center;
        background: green;
        color: white;
        position: absolute;
        top: 150px;
        right: 50px;
        overflow: hidden;
        width: 60px;
        height: 250px;
    }
    #posts {
        position:absolute;
        top: 0;
        bottom: 0;
        width: 100%;
        overflow: auto;
    }
    #photo,#quote {
        margin-top: 800px;
        height: 300px;
    }
    ​
    

    HTML

    <div id="navigator">Scroll down to change background</div>
    
    <ul id="posts">
        <li id="photo">photo section</li>
        <li id="quote">quote section</li>
    </ul>​
    

    jQuery

        // cache the elements
    var $nav = $('#navigator');
    var $photo = $('#photo');
    var $quote = $('#quote');
    var $posts = $('#posts');
    
       // get the view area of #posts
    var top = $posts.offset().top;
    var bottom = top + $posts.height();
    
       // run code when #posts is scrolled
    $posts.scroll(function() {
        if($quote.offset().top < bottom) {
            $nav.css('backgroundColor', 'red');
        } else if ($photo.offset().top < bottom) {
            $nav.css('backgroundColor', 'blue');
        } else {
            $nav.css('backgroundColor', 'green');
        }
    });
    

    ​

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

Sidebar

Related Questions

I came across materialized views, which look great: http://en.oreilly.com/mysql2011/public/schedule/detail/17146 However there is too much
I was (re)reading Joel's great article on Unicode and came across this paragraph, which
I came across this great replacment for the getstatusoutput() function in Python 2.* which
I recently came across a great data structures book, Data Structures Using C (c)
I recently came across a Windows library called AHK that gives me great control
I came across a piece of code which looks like this: jQuery(function($) { $('#saySomething').click(function()
I came across this great JQuery example of using a slidetoggle. I want to
Recently came across pidgin . Its great, and does what I want, but I
First of all, it's great. However, I came across a situation where my benchmarks
I came across this function of converting a SimpleXML Object to an array here

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.