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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:21:27+00:00 2026-06-18T14:21:27+00:00

I’ve made simple gallery with use of basic CSS,HTML, and jQuery, but it has

  • 0

I’ve made simple gallery with use of basic CSS,HTML, and jQuery, but it has few bugs, and I can’t figure out whats wrong. It works fine in Firefox, but not in other browsers. Here is the code

$(document).ready(function(){

 var x=0; var lava=0;
  //right arrow
$("#p_sipka").click(function(){
  if(x<9){
          x++; //used as a "position counter"
          lava = parseInt($("#slider").css("left"), 10); //parse a value of slider css.left property into var lava
          lava=lava-800; //substract 800 (pixels) - WORKS FINE IN FIREFOX, THROWS NaN in other browsers
          $("#slider").css("left",lava);  //set new value to slider
         }
  else if(x==9){
                $("#slider").css("left","0px");
                x=0;
               }    
});

First problem:
It should move slider div which is 8000px wide, one page is 800px wide, so to move gallery to left or right I change left property of slider div with clicking on arrows. I tried to debug it somehow.
Firefox Firstly, value of x is 0 then, when I click on right arrow (by the way left arrow works just fine in any browser) value of x is 1, and left property is changed to -800(No, not 800px, because I have to use parseInt, but it works).
Other browsers: It changes value of x but do not change left property.alert(x) throws 1 as it should but left property throws NaN, and after 10clicks, it starts working, as it should, but it still throws NaN.
Second problem:
CSS Transition.
I wanted to make my gallery nice and animated, so I used CSS transition property and set it to 1second;. It works fine, it takes 1second to change pages. So it is nicely changing left property for example from 800px to 1600px. But when I click on my arrown second time, and first animation is not finished yet, it adds or substract another 800pixels to a value which is set in that very second. For example, I click, it is changing from 800 to 1600 but when I click when left value is about 500px, it adds 800px and left value is now 1300px, and my gallery doesn’t look as it should. Is there any way to prevent my jQuery code to run again until first animation is finished?

Here is whole code
http://jsfiddle.net/QuyjZ/

  • 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-18T14:21:29+00:00Added an answer on June 18, 2026 at 2:21 pm

    first problem


     lava = parseInt($("#slider").css("left").replace(/px$/i,""), 10)
    

    second problem …


    lava = math.Ceil(parseInt($("#slider").css("left").replace(/px$/i,""), 10)/800)*800
    

    but in fact you should count the number of page instead & multiply the index * 800 to get your position

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I upgraded downgraded to rails 2.3.17 due to the security bugs, but now I
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am confused How to use looping for Json response Array in another Array.

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.