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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:13:17+00:00 2026-05-23T08:13:17+00:00

I have a cycle that it’s just working for my last element. It was

  • 0

I have a cycle that it’s just working for my last element. It was suposed to work for each element.

for (var z=1; z<$('.page').length;z++){ 

$('#arrowUp_'+z).click(function(){
        $('#thumbsContainer_'+z).animate({top: '-='+93+'px'}, {duration: 1000});
        cont++;
        arrowThumbs();
    });

    $('#arrowDown_'+z).click(function(){
        $('#thumbsContainer_'+z).animate({top: '+='+93+'px'}, {duration: 1000});
        cont--;
        arrowThumbs();
    });
}

If I replace z for one number I can make it working for that case. But I don´t want to repeat the same process N time. So I thought it was good idea to make a a cycle for…but no success

Can anyone explain how to do that??
Thanks

  • 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-23T08:13:17+00:00Added an answer on May 23, 2026 at 8:13 am

    Why are you using IDs? why can’t you just add a class on each element like so

    <div id="arrowUp_1" class="arrowUp">
    
    </div>
    

    $('.arrowUp').click(function(){...});

    also [things you should know]

    ‘-=’+93+’px’ its pointless you can have ‘-=93px’ still be the same thing as it would be consider as a string not a number its just like saying var h3ll0; is not a string 🙂

    cont++ is not predefined before and your whole don’t work because animate() is wrong…
    click the link so u can get some help with it http://api.jquery.com/animate/

    you do not put {duration:1000} just put 1000 as that is an attribute on its own and expects a number [of milliseconds not a json object]…

    UPDATE
    check this code…

    http://jsfiddle.net/JFRAb/3/

    ==============================================

    CSS:

    span {background: red;position: absolute; left: 0;}

    JS

    $(function() {
        $('div').click(function() {
            $('p').append($(this).text());
            //alert('text');
            var i = $(this).index($('ul div'));
            console.log($(this));
            $('ul span').eq(i).animate({
                left: '50%'
            }, 1000);
        });
    });
    

    HTML

    <p>Test...</p>
    <hr />
    <ul>
        <div>Click 1</div>
        <div>Click 2</div>
        <div id="b">Click 3</div>
        <div>Click 4</div>
    </ul>
    <br /><br /><br /><br />
    <ul>
        <span>Im thumb 1</span>
        <span>Im thumb 2</span>
        <span>Im thumb 3</span>
        <span>Im thumb 4</span>
    </ul>
    

    This is a bad example of element choice 🙂 but its better solution for you 🙂 I should think 🙂

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

Sidebar

Related Questions

I have this page that displays pictures in a div. I have jquery cycle
I have a division operation inside a cycle that repeats many times. It so
I have three images that I want to cycle through when clicking on a
Being a Java developer in an agile development cycle, I have learnt that it
I have a table that is similar to: cycle | id | name ------|-------|------
I have a for cycle that iterates over an associative array. foreach entry i
I work for a large company that has adopted sharepoint. I have been tasked
I have a jquery cycle slideshow that slides through 3 big photos and is
As part of our development life cycle we have a number of process that
I am using the cycle jquery plugin. I have a few images that fade

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.