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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:06:22+00:00 2026-06-14T15:06:22+00:00

Alright. I am completely stumped here. I have a horizontal scrolling list that, when

  • 0

Alright. I am completely stumped here.

I have a horizontal scrolling list that, when you cannot scroll anymore, the button/arrow changes color (via addClass removeClass). My fiddle works (almost) perfectly. My code on the other hand does not…

The fiddle: http://jsfiddle.net/4rKPT/8/

jQuery:

$(document).ready(function() {

    var $item = $('div.mainBodyContentListItem'),
        //Cache your DOM selector
        visible = 2,
        //Set the number of items that will be visible
        index = 0,
        //Starting index
        endIndex = ($item.length / visible) - 1; //End index
    $('div.mainBodyContentArrowR').click(function() {
        if (index < endIndex) { //can scroll
            index++;
            $item.animate({
                'left': '-=592px'
            });
        }
    });

    $('div.mainBodyContentArrowR').click(function() {
        if (index > endIndex) { //can't scroll
            $('div.mainBodyContentArrowR').addClass('disable');
        }
    });

    $('div.mainBodyContentArrowR').click(function() {
        if (index < endIndex) { //can scroll
            $('div.mainBodyContentArrowL').removeClass('disable');
        }
    });



    $('div.mainBodyContentArrowL').click(function() {
        if (index > 0) { //can scroll
            index--;
            $item.animate({
                'left': '+=592px'
            });
        }
    });

    $('div.mainBodyContentArrowL').click(function() {
        if (index < 0) { //can't scroll
            $('div.mainBodyContentArrowL').addClass('disable');
        }
    });

    $('div.mainBodyContentArrowL').click(function() {
        if (index > 0) { //can scroll
            $('div.mainBodyContentArrowR').removeClass('disable');
        }
    });


});

This works as it should (except haven’t figured out how to fix the issue that going back left and hitting the end of the scroll again, as it was when the page loads, doesn’t add the class back and change the color – feel free to address, but it’s not the issue of this thread).

My actually code does it correctly in this instance:

 $('div.mainBodyContentArrowR').click(function() {
            if (index < endIndex) { //can scroll
                $('div.mainBodyContentArrowL').removeClass('disable');
            }
        });

But nowhere else. I am stumped here. The odd thing is, that line I’ve outlined above is working properly. The ‘disable’ class is being removed on the first click and then those addClass removeClass lines don’t do anything (the scrolling back and forth does work and stop properly).

Please any help is appreciated. I feel like I’m just staring at a 50 foot brick wall and just can’t see my way through or over.

  • 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-14T15:06:23+00:00Added an answer on June 14, 2026 at 3:06 pm

    If you change

    if(index < endIndex)
    

    to

    if(index <= endIndex)
    

    Does it work?

    The other problem that you have mentioned ( not the topic of this thread should also get fixed if

    if(index > 0)
    

    is changed to

    if(index >= 1)
    

    I knew the problem you mentioned in the comment was coming. To fix that problem you would need to add following line after the line that calculates the end index

    if(($item.length % visible) == 0){
        enIndex = endIndex - 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, currently I have my SWF hitting a php file that will go and
Alright, I am not completely sure that I worded the title right, but I
Alright so a quick SQL question here(using sql-server-2008). I have a mapping table names
I have a very simple table structure here. Just a list of words related
Alright so here is my problem. Basically I have a string with 4 words
Alright, I have some data that I need to assign an int type identifier
Alright, I'm completely stumped by this one. Firefox (FF 11/OS X) is rendering a
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright so i need to open a .txt file that will be created in
Alright so I have no idea how to even begin doing this But basically

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.