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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:27:53+00:00 2026-06-13T19:27:53+00:00

Basically, this advances to the next hidden span when clicked. The markup: <div id=facts>

  • 0

Basically, this advances to the next hidden span when clicked.

The markup:

<div id="facts">
    <span>click to cycle</span>
    <span>fact 1</span>
    <span>fact 2</span>
    <span>fact 3</span>
    <span>fact 4</span>
</div>

The js:

$(document).ready(function() {
    var current = 1;
          $('#facts span').click(function() {
              // Hide all of them
              $('#facts span').hide();
              // Unhide the current one:
              $('#facts span:eq(' + (current % $('#facts span').length) + ')').show();
              // Increment the variable
              console.log(current % 4);
              current++;
          });

    // Unhide the first one on load
    $('#facts span:first-child').show();
});​

What I’m trying to do now is remove the first span after it’s been clicked, because it is not necessary for the user to see the ‘click to cycle’ instruction again.

  • 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-13T19:27:56+00:00Added an answer on June 13, 2026 at 7:27 pm

    Assign a specific id to the original one and a class to the others.

    <span id='removeme'>click to cycle</span>
    <span class='cycleme'>fact 1</span>
    <span class='cycleme'>fact 2</span>
    <span class='cycleme'>fact 3</span>
    <span class='cycleme'>fact 4</span>
    

    Show the removeme and hide all the others via CSS

    #removeme {
      display: inline;
    }
    span.cycleme {
      display: none;
    }
    

    In the script, bind a click event to the original one to simply remove it. The subsequent ones get the same handler as they had before.

    $(document).ready(function() {
        // Initialize
        var current = 1;
    
       // Bind the first one's onclick to remove itself
       $('#removeme').click(function() {
          $(this).remove();
          // And display the first one
          $('#facts span:first-child').show();
       });
    
    
       // Target the others via their class
       $('#facts span.cycleme').click(function() {
          // Hide all of them
          $('#facts span').hide();
          // Unhide the current one:
          $('#facts span:eq(' + (current % $('#facts span.cycleme').length) + ')').show();
          // Increment the variable
          current++;
       });
    });​
    

    Here is the live example

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

Sidebar

Related Questions

I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
Basically this is a question how to access local scope handler. I trying to
So basically this code: class A { }; class B { B (const B&
So basically this code was working fine before. I had some computer issues and
The criteria is basically this: folders will exist for about 24-48hrs folders names can
The problem is basically this, in python's gobject and gtk bindings. Assume we have
i'm studying this source base . Basically this is an Anim server client for
My understanding is that Ladner's theorem is basically this: P != NP implies that
I'm trying to make the so called fine tune thing. Basically this looks like:
I'm working on a new CMS to use on repeative projects. Basically this chunk

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.