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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:28:51+00:00 2026-05-25T19:28:51+00:00

So my code works to a degree. I have a slider, with some left

  • 0

So my code works to a degree. I have a slider, with some left & right buttons.

What I’m trying to do is make sure that it can’t slide past a certain point one way or the other, as there will be a fixed number of slides. So I’ve introduced a variable called slideWidth which I’m trying to use to keep track of the current margin. If it reaches a certain number I only want one button to work. My code below doesn’t seem to change though – I can hit the left button unlimited times, and never the right…

<script>
$(document).ready(function() {

var slideWidth=0;

if (slideWidth == 0)
 {

    $("#slideLeft").click(function(){
      $(".slideOverflowHide").animate({"margin-left": "-=1100px"}, "slow");
      slideWidth = slideWidth - 1100;
    });

 }else if (slideWidth == -3300){

     $("#slideRight").click(function(){
      $(".slideOverflowHide").animate({"margin-left": "+=1100px"}, "slow");
      slideWidth = slideWidth + 1100;
    });

 }else{

    $("#slideRight").click(function(){
      $(".slideOverflowHide").animate({"margin-left": "+=1100px"}, "slow");
      slideWidth = slideWidth + 1100;
    });

    $("#slideLeft").click(function(){
      $(".slideOverflowHide").animate({"margin-left": "-=1100px"}, "slow");
      slideWidth = slideWidth - 1100;
    });

 }

});
</script>
  • 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-25T19:28:52+00:00Added an answer on May 25, 2026 at 7:28 pm

    This code is inside out. You should be performing the width check inside the click functions.

    $("#slideLeft").click(function(){
      if(slideWidth == 0) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JUnit test that is checking to make sure that a customized
This code works correctly to make a web service call: int numberOfGuests = Convert.ToInt32(search.Guest);
I have created some JQuery that on click of specified HTML it then becomes
A calculator program I have created works almost perfectly with the exception that Math.Sin()
I have a need to write code that will prorate a value across a
I have a little sample application I was working on trying to get some
I am trying to add a simple figure into my latex code .I have
what i have here works exactly how i want it. My question is that
I have an object called point that I can move around the screen with
I'm writing a program using JOGL/openCL to utilize the GPU. I have code that

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.