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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:41:31+00:00 2026-05-28T18:41:31+00:00

I need to set up jQuery to cycle through table rows. The table should

  • 0

I need to set up jQuery to cycle through table rows. The table should always show only one row. When I click the link, the previous row or the next row should be shown.

The basic HTML structure is:

<div>
<a href="">Next</a>
<table>
  <tr><td>text1</td></tr>
  <tr><td>text2</td></tr>
  <tr><td>text3</td></tr>
  <tr><td>text4</td></tr>
</table>
<a href="">Previous</a>
</div>

Any help would be appreciated.

  • 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-28T18:41:33+00:00Added an answer on May 28, 2026 at 6:41 pm

    First, give ids to your elements:

    <a id="next" href="">Next</a>
    <table id="myTable">
        <tr><td>text1</td></tr>
        <tr><td>text2</td></tr>
        <tr><td>text3</td></tr>
        <tr><td>text4</td></tr>
    </table>
    <a id="prev" href="">Previous</a>
    

    Then, hide all elements except for the first one:

    $("#myTable tr").hide().eq(0).show();
    

    Finally, make the “Next” and “Previous” buttons toggle the visibility of the adjacent siblings, if exist:

    $("#next").click(function(e) {
        e.preventDefault();
        $("#myTable tr:visible").next().show().prev().hide(); // Will do nothing if the visible element is the last one
    });
    
    $("#prev").click(function(e) {
        e.preventDefault();
        $("#myTable tr:visible").prev().show().next().hide(); // Will do nothing if the visible element is the first one
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to set up jquery to cycle through tables, making sure it shows/hides
I need to replace the only item in a jQuery set, which contains only
I have been researching the JQuery way to add table rows dynamically. One excellent
I need to set a single property in a jQuery command using a value
How to set radio option checked onload with jQuery? Need to check if no
I need to set a PHP $_SESSION variable using the jQuery. IF the user
I need to set the value of a session with jquery. im thinking i
Using jquery, I need to set the class of a div using a select
I have a Jquery Cycle slideshow that has a click function to animate a
I need to use jQuery to set the focus to the element with the

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.