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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:38:50+00:00 2026-05-31T04:38:50+00:00

I’m pretty new to JQuery so I made my own light box that comes

  • 0

I’m pretty new to JQuery so I made my own light box that comes up and an exit button, it works great. I was just wondering how to make it so I can have a Next and Previous button and it will view the next image or div with the proper class assigned to it. For example, My HTML:

<button id="button1">Click Here</button>

<div id="view" class="outter">
    <img src="http://go.iomega.com/static/img/x_button_close.png" class="exit_button" id="close_view" />
        <div class="inner">
            <h1>stuff inside of the first div</h1>
        </div>
    <button id="previous">Prev</button><button id="next">Next</button>
</div>

<div id="view" class="outter">
    <img src="images/closebox.png" class="exit_button" id="close_view" />
        <div class="inner">
            <h1>stuff inside of the second div</h1>
        </div>
</div>

MY CSS

.outter{
    display:none; 
    width:620px; 
    height:380px; 
    top:20%; 
    left:17.5%; 
    position:absolute;
    z-index:2; 
}
.inner{
    width:600px; 
    height:330px; 
    background-color:white; 
    border:1px solid #000; 
    -moz-box-shadow:0px 0px 10px #111; 
    -webkit-box-shadow:0px 0px 10px #111; 
    box-shadow:0px 0px 10px #111; 
    margin-top:15px;
    z-index:1; 
}
.exit_button{ 
    float:right;
    z-index:3;
}
​

And My JQuery

$(document).ready(function(){
        $('#button1').click(function(){ 
            $('#view').fadeIn(750);
        }); 
        $('#close_view').click(function(){ 
            $('#view').fadeOut();
        }); 
}); ​

Here is all of that in a JSFiddle
http://jsfiddle.net/9cU5C/29/

This all works fine but I’d like to be able to add a whole bunch of div’s with the class “outter” in there and have the next button flip to the next “outter” classed div in line and vise versa with the previous button. I hope I’m explaining this properly and don’t sound stupid, I’m pretty new to JQuery and I enjoy doing things like this myself to get better at it. I tryed to google the problem, and found couldn’t come up with anything that I could get to work.

Thanks a bunch guys!
-Mike

  • 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-31T04:38:52+00:00Added an answer on May 31, 2026 at 4:38 am

    make use or .next(), .prev(), and .closest(). Also, set classes on your ‘next’ and ‘previous’ buttons.

    pseudo:

    $('.next').click(function() {
       $('.outter').hide();
       $(this).closest('outter').next('outter').show();
    });
    
    $('.previous').click(function() {
       $('.outter').hide();
       $(this).closest('outter').prev('outter').show();
    });
    

    The concept is to hide all the elements, then make the appropriate one visible.

    After you’re done with your learning exercise, definitely check out the code for lightbox and see how it’s done. It’s always great to try first, and then find out the ‘best’ approach.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a

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.