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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:53:17+00:00 2026-06-18T11:53:17+00:00

ive a problem which is driving me crazy. im trying to explain… i have

  • 0

ive a problem which is driving me crazy. im trying to explain…
i have a very long scrolling page with about 10 divs, one below the other (no space between).
at the bottom of the viewing port is a button with an id and a position: fixed. when i scroll up or down the button is fixed while the divs move up or down.
i want to have different id’s on the button depending on which div layer is in the viewing port. that means if one divlayer fills over 50% of the available space the href of the button should change…
i tried the inview.js, but the problem is, that 2 divs at the same time have the inview class…

my current code:

$('#div4, #div5, #div6').bind('inview', function (event, visible) {
        if (visible == true) {
        $(this).addClass("inview");

        } else {

        $(this).removeClass("inview");
        }
    });





var $div4 = $('#div4');

if($div4.hasClass("inview")){
    $('#button1').attr('id', 'button2'); 
  }

you see, every div which is in the viewport the button gets a new id.
has anyone of you a solution?
thanks ted

  • 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-18T11:53:18+00:00Added an answer on June 18, 2026 at 11:53 am

    You can try to remove the inview class before adding it.. Something like this:

    var $divs = $('#div4,#div5,#div6';
    $divs.bind('inview', function (event, visible) {
            $divs.not(this).removeClass("inview");
            if (visible == true) {
              $(this).addClass("inview"); 
            }
         });
    

    Another suggestion is to use the Waypoints plugin and fire when the div crosses the 50% mark.

    The only difficult part is that depending on the direction you’ll need to select the current div or the one above.

    Plugin: http://imakewebthings.com/jquery-waypoints/

    Demo: http://jsfiddle.net/lucuma/nFfSn/1/

    Code:

     $('.container div').waypoint(function (direction) {
            if (direction=='up')
                alert('hit ' + $.waypoints('above')[$.waypoints('above').length-2].id);
            else
                alert('hit ' + $(this).attr('id'));  
        }, {
            offset: $.waypoints('viewportHeight') / 2
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem with a mysql ERM which is currently driving me crazy.
Ive got the following problem. I have a model called user which has a
I have this problem driving me crazy. I have spent decades to figure it
This problem is driving me crazy. I'm trying to change the viewController when the
I have a problem that has been driving me crazy and I'd appreciate any
I have a problem which has been driving me mad for days - I've
This one's driving me crazy... I have a loop which adds an event listener
I'm facing a huge problem here which is driving me crazy, I've made an
I've got a problem which is probably very easy to solve but I can't
I have a problem in a VB.Net class library which I have simplified greatly

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.