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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:02:05+00:00 2026-05-31T08:02:05+00:00

it works if I do this: $(document).ready(function() { $(‘.button1’).click(function() { var get_id = $(this).attr(‘id’);

  • 0

it works if I do this:

$(document).ready(function() {
    $('.button1').click(function() {
        var get_id = $(this).attr('id');
        $('.outter').fadeIn(750);
        $('#div_'+get_id).show();

    });
    $('.exit_button').click(function() {
        $('.outter').fadeOut();
        $('.inner_content').hide();
    });

    $('.next').click(function() {   
        var current1 = $('.inner_content:visible');                     
                current1.hide();
        current1.next('.inner_content').show();  

    });

    $('.previous').click(function() {
        var current2 = $('.inner_content:visible');
        current2.hide();
        current2.prev('.inner_content').show(); 

    });


});

But I want the previous and next buttons to disable when they come to the last or first in their class so I do this:

$(document).ready(function() {
    $('.button1').click(function() {
        var get_id = $(this).attr('id');
        $('.outter').fadeIn(750);
        $('#div_'+get_id).show();

    });
    $('.exit_button').click(function() {
        $('.outter').fadeOut();
        $('.inner_content').hide();
    });

    $('.next').click(function() {   
        var current1 = $('.inner_content:visible');
        var get_id2 = current1.attr('id');
        if(('#'+get_id2+'.inner_content').is(':last'))
        {
        }
        else
        {   
        current1.hide();
        current1.next('.inner_content').show();  
        }
    });

    $('.previous').click(function() {
        var current2 = $('.inner_content:visible');
        var get_id3 = current2.attr('id');      
        if(('#'+get_id3+'.inner_content').is(':first'))
        {
        }
        else
        {
        current2.hide();
        current2.prev('.inner_content').show(); 
        }
    });


});

But I can’t get that to work at all.

My HTML:

<img src="thumbs/1.jpg" class="button1" id="pic_01" />
<img src="thumbs/2.jpg" class="button1" id="pic_02" />
<img src="thumbs/3.jpg" class="button1" id="pic_03" />
<img src="thumbs/4.jpg" class="button1" id="pic_04" />

<div class="outter">
    <img src="http://go.iomega.com/static/img/x_button_close.png" class="exit_button" />
        <div class="inner">

          <div class="inner_content"  id="div_pic_01">
            <img src="thumbs/1.jpg" />
          </div>
          <div class="inner_content"  id="div_pic_02">
            <img src="thumbs/2.jpg" />
          </div>
          <div class="inner_content"  id="div_pic_03">
            <img src="thumbs/3.jpg" />
          </div>
          <div class="inner_content"  id="div_pic_04">
            <img src="thumbs/4.jpg" />
          </div>  

        </div>   
    <button class="previous">Prev</button><button class="next">Next</button>
</div>

And my CSS:

.outter{
    display:none; 
    width:620px; 
    height:380px; 
    top:20%; 
    left:17.5%; 
    position:absolute;
    z-index:4; 
}
.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:3;
}
.exit_button{ 
    float:right;
    z-index:5;
}
.inner_content{
    display:none; 
}

I hope this makes sense. So like when you’re scrolling through with the previous and next buttons and the last picture comes up, you can’t go any more forward, you can only go backwards or vise versa.

here’s a quick example I put together in this fiddle http://jsfiddle.net/DadYW/7/ hope it makes some kind of sense, I’m very new to JQuery, this is one of my first few projects I’m trying on my own.
Thanks a bunch
-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-31T08:02:06+00:00Added an answer on May 31, 2026 at 8:02 am

    I would disabled the button (or hide it as you wish) after the navigation to the next or previous, not when clicking:

    $('.next').click(function() {    
    
        var current1 = $('.inner_content:visible'),
            $next = current1.next('.inner_content');
    
        // hide current / show next
        current1.hide();
        $next.show();
    
        // if next is last, disable the button
        if ($next.is(':last-child')) {
            $(this).prop('disabled', true);
        }
    
        // enable the previous button
        $('.previous').prop('disabled', false);
    });
    
    $('.previous').click(function() {
    
        var current2 = $('.inner_content:visible'),
            $prev = current2.prev('.inner_content');
    
        // hide current / show previous
        current2.hide();
        $prev.show();
    
        // if previous is first, disable the button
        if ($prev.is(':first-child')) {
            $(this).prop('disabled', true);
        }
    
        // enable the next button
        $('.next').prop('disabled', false);
    });
    

    DEMO

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

Sidebar

Related Questions

$(document).ready(function(){ $('.choices a img').click(function(e) { var url = $(this).attr('href') + ' .con_cen2'; $('.con_cen').html('loading...').load('signup.html'); e.preventDefault();
I have some jQuery code something like this: $(document).ready(function() { $(img.off).click(function() { alert('on'); $(this).attr('class',
This works great: $(document).ready(function() { var previewwidth = ($(window).width() - ( $('.aside').width() + $('.results').width()
function barvaInfo(event) { $(document).ready(function(){ var nid = window.event.srcElement.id; } this works in IE but
following up from yesterday... This portion of the code does work. $(document).ready(function(){ $('#listMenu a').click(function
This works for running the same code on both ready and resize: $(document).ready(function() {
<script type=text/javascript> $(document).ready(function() { alert(Hello jQuery.); }); </script> This works the first time I
I have this: jQuery(document).ready(function(){ jQuery('a.color2030').click( function() { jQuery('tbody').hide(); jQuery('tbody.color2030').show(); }); jQuery('a.color2031').click( function() { jQuery('tbody').hide();
I have this javascript code: $(document).ready(function() { var leftHeight = $('#maincontent').height(); $('#sidemenu').css({'height':leftHeight}); }); This
My jquery code looks like this: $(document).ready(function() { $('.French').click(function(){ changeBackground(); }); }); function changeBackground(){

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.