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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:07:40+00:00 2026-05-30T22:07:40+00:00

I am trying to make prev – next sliding between content on a page.

  • 0

I am trying to make prev – next sliding between content on a page. I have the following markup:

<div class="right">
     <a href="javascript:;" class="light-button" id="previous-button">Previous</a>
     <a href="javascript:;" class="light-button" id="next-button">Next</a>
 </div>
 <?php foreach ($chapters as $chapter) : ?>
 <div id="chapters-container-<?php echo $chapter->id; ?>" style="display: none">
     <div class="left">
         <h1 class="hmc"><?php echo $chapter->title; ?></h1>
     </div>
     <ul class="attachments scroll-pane">
     <?php foreach ($chapter->files as $file) : ?>
     <!--video zone-->
         <?php if ($file->extension == '.mpeg') : ?>
         <li class="wide">
             <img src="" />
             <span class="duration hmc"><?php $file->duration; ?></span>
             <h1 class="hmc">The title is a title</h1>

         </li>
         <?php endif; ?>                              
     <?php endforeach; ?>
     </ul>
</div>
<?php endforeach; ?>
</div>

Basically I generate some content dynamically with PHP. I have wrapped each content generated in a div and I do not display it only with jQuery.
Now I tried doing something like:


$('body').on('click', 'a#next-button', function(){
    $('#chapters-container-').next();
});

but ofc it is not working as I want it. How can I make the content change when i toggle between prev and next button based on the markup I am generating.

  • 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-30T22:07:41+00:00Added an answer on May 30, 2026 at 10:07 pm

    I think that you don’t get what

    $('#chapters-container-').next(); 
    

    does. This, according to the documentation,

    Get the immediately following sibling of each element in the set of
    matched elements. If a selector is provided, it retrieves the next
    sibling only if it matches that selector.

    so you are just selecting the next element after the element with id = chapters-container-

    Youy should do something like:

    $('body').on('click', 'a#next-button', function(){ 
      var visisbleContainer = $('div[id^=chapters-container-]:visible');
      visisbleContainer.next().show();
      visisbleContainer.hide(); 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make a sliding panel where you can click next and back to
Right now I'm trying make some browser based game. But I have little questions.
Trying to make a MySQL-based application support MS SQL, I ran into the following
trying to make a page which will recursively call a function until a limit
Im trying make a menu with the next structure: -category 1 --category 1.1 ---category
I wrote the following code when trying to make a doubly-linked list with an
I am trying to make my page reload after sorting through the new position,
I am trying make long screen to vertical direction. So, I need a screen
Trying to make a make generic select control that I can dynamically add elements
Trying to make a generic PL/SQL procedure to export data in specific XML format,

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.