CyberShot Posted November 29, 2009 Share Posted November 29, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/183263-jquery-help/ Share on other sites More sharing options...
.josh Posted November 29, 2009 Share Posted November 29, 2009 yes. They are indexed, just like arrays (starting at 0). so first one would be 0, 2nd one 1, 3rd 2, etc... Quote Link to comment https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-967578 Share on other sites More sharing options...
JustLikeIcarus Posted December 1, 2009 Share Posted December 1, 2009 Well if you always want to show the one you click and the next one after you would do like $(this).show().next().show(). More information on when you want items to be shown is needed to better understand what your trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-968948 Share on other sites More sharing options...
CyberShot Posted December 1, 2009 Author Share Posted December 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-969142 Share on other sites More sharing options...
rajivgonsalves Posted December 1, 2009 Share Posted December 1, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-969165 Share on other sites More sharing options...
CyberShot Posted December 1, 2009 Author Share Posted December 1, 2009 thanks, i will try that out. i only understand about half of it. so this should be fun Quote Link to comment https://forums.phpfreaks.com/topic/183263-jquery-help/#findComment-969166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.