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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:57:12+00:00 2026-06-16T17:57:12+00:00

I have page with two buttons (scroll left and scroll right), and on click,

  • 0

I have page with two buttons (scroll left and scroll right), and on click, page have to go left and right by div width (every div have different width). Could this be done with jQuery? I don’t know how to read current div id (one close to left side of border), and how to define scroll (left or right) by width of previous/next div?

  • 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-16T17:57:13+00:00Added an answer on June 16, 2026 at 5:57 pm

    On click just increase, decrease a Counter var c.
    This will help us to target the desired DIV by .eq( c )
    Than all we need is to get the desired DIV .offset().left and move the page to that position:

    jsBin demo

    HTML (add a .box to your DIVs):

    <div class="box" id="01" style="width:200px; height:100px; border:solid 1px; float:left">div01</div>
    

    jQuery:

    $(function(){
    
      var c = 0;
      var boxN = $('.box').length;
      
      $('#left, #right').on('click', function( e ){
        
        e.preventDefault();
       
        c = this.id=='right' ? ++c%boxN : --c ;
        if(c<0){ c=boxN-1; }
        var boxL = $('.box').eq( c ).offset().left;
        
        $('html, body').stop().animate({scrollLeft: boxL});
        
        
      });
      
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different buttons on my page. I want them both to be
I have two forms, and so two different submit buttons, for one page (page
I have a page whereby the user can press left + right buttons to
I have a page with two buttons, one Button opens a popup window with
I have an aspx page with two buttons, one of the buttons has an
I have a page with two Listviews (with two different data sources). I have
I have created an app wherein I have a large scroll view (two page
i have a aspx page with two buttons,close and submit button.when i press the
I am using Page.Isvalid function in my web page.I have two buttons in my
I have a form with two buttons in ASPX page. One to print with

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.