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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:37:13+00:00 2026-06-09T17:37:13+00:00

I need to create an effect, preferably in jQuery, where an element scrolls down

  • 0

I need to create an effect, preferably in jQuery, where an element scrolls down with the page and snaps to different “anchors”.

In my case, i have to build a product listing for a webshop where the “add to cart” button snaps next to the price for each product and when the user scrolls down, at a certain point, break loose from the current product and scroll down and snap to the next one.

I’v been googling for solutions and plugins but have not found anything covering this.

Any suggestions is highly appreciated. I guess this is done at least once before and/or exists as a plugin or tutorial 🙂

Edit:

To illustrate what i mean i made a page here:

http://retype.se/temp/scrolltest.html

What i need is when the user scrolls down trough products, the yellow div will at a certain point when next product is in focus, snap loose and scroll down and snap to next product.

Bad design in my opinion, but i just try to please 🙂

  • 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-09T17:37:14+00:00Added an answer on June 9, 2026 at 5:37 pm

    This is the dirtiest 5 minute example ever.

    I’ll omit the CSS and HTML because they’re really of little concern, as long as you understand that a moving element needs position:absolute; and that the first container with a position:anything will be the offset() container we use.

    //log each x,y coordniate into an array
    var theCoords = [];
    $.each($('.price'), function(i,obj){
      theCoords.push({
        'ele' : $(obj),
        'top' : $(obj).offset().top,
        'left' : $(obj).offset().left});
    });
    

    In the above, we push some information about the elements we want to snap to into an array.
    We store the literal element reference within the param of ‘ele’.

    $(window).on('scroll', function(){
      $.each(theCoords, function(i, arr){
        if($(window).scrollTop() > arr.top - 75){
          $('#addToCart').css({
            'top': arr.top
          });
          $('#addToCart').prop('rel', arr.ele);
        }
      });  
    });
    

    In the above, we capture the window scorll event, we iterate over each of theCoords everytime the page scrolls. I’ve just used some dirty math to make the example flow at intervals I found to be acceptable; you’re welcome to change this. We used #addToCart as our position:absolute element, and each time we evaluate the position of the window against our array, we move the ‘top’ based on the closest match to the array. We also push the reference to the ‘price’ object into the ‘rel’ property of our cart.

    $('#addToCart').click(function(){
      console.log($($(this).prop('rel')).text());
    });
    

    Here, if you click, you’ll get the text of the div that we snap to.

    Hopefully this gets you going in the right direction.

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

Sidebar

Related Questions

I am trying to create a ripple effect with Jquery. By having an element
I need a jQuery plugin to create type effect. Is there anyone or should
I need to create a slide effect for 2 different html elements, but this
I need to create more than one UIView with MARQUEE effect like HTML <marquee>
I need to create some simple effects for the layers which I have created
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler
I need to create 3d depth effect for my image. Number 1 is what
I have a set of numbers with varying precision. I need to create a
I'm using a piece of JQuery to create the effect described at this website:
I need to create this effect in HTML Colhemos ideias, semeamos futuro... Is this

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.