Jump to content

jquery help


CyberShot

Recommended Posts

I have multiple <ul> lists in my code. I am hiding all of them using ("ul").hide();

 

What I want is to be able to show 2 of them at a time. I know I can do it using ("ul:eq(0)").show. That will show the first one, but how do I get it to show the first and second. which would be 0 and 1, and then 2 and 3 and so on?

Link to comment
https://forums.phpfreaks.com/topic/183263-jquery-help/
Share on other sites

i am  trying to build a photogallery. So the thumbnails will have 4 pages on the right all four will be hidden. then a main image on the left. Below the main images will be four dots. The first dot will be blue to indicate the first page is active, the rest will be gray. When you click on the second dot, it will turn blue and the first dot will turn gray to indicate the second page is active and all others are inactive. I played with the jquery function prevAll, but it only worked going one way, it would work on the next one, but not the previous on. going up would work fine, going back would turn all dots blue

Link to comment
https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-969142
Share on other sites

maybe this will help you a bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> Iteration </TITLE>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
    $('#next').click(function() {
       var index = $('#test').children(':visible:first').attr('index');

       if (!index || (parseInt(index)+1) == $('#test').children().size()) {
             index = 0;
       }
       else {
             index = parseInt(index) + 1;
       }
       $('#test').children().hide();
       $('#test').children().eq(index).show();
       $('#test').children().eq(index+1).show();
        
    });
    
});

</script>

</HEAD>

<BODY>

<ul id="test">
    <li style="display:none" index='1'>Test 1</li>
    <li style="display:none" index='2'>Test 2</li>
    <li style="display:none" index='3'>Test 3</li>
    <li style="display:none" index='4'>Test 4</li>
    <li style="display:none" index='5'>Test 5</li>
    <li style="display:none" index='6'>Test 6</li>
</ul>
<br />
<input type="button" id="next" value='Iterate'/>
</HTML>

 

Link to comment
https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-969165
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.