CyberShot Posted January 10, 2010 Share Posted January 10, 2010 I am using jquery to make my own navigation for some pagination. I know how to do it this way I have a list <ul class="pages"> </ul> <ul class="pages"> </ul> <ul class="pages"> </ul> <ul class="pages"> </ul> So that is 4 ul's with the class of pages. So I can use jquery to pick that up in an array by doing $(".pages:eq(0)").show(); that would show the first ul, I could hide all other pages by doing $(".pages").hide(); simple enough. Now I want to make a link for the pagination, so I do this <a href="#" class="pageLink">1</a> <a href="#" class="pageLink">2</a> <a href="#" class="pageLink">3</a> <a href="#" class="pageLink">4</a> and I wrote a click event for it like so $(".pageLInk:eq(1)").click(function(){ { $(".pages").hide(); $(".pages:eq(1)").show(); } That's about as simple a pagination script I can get. I don't think it gets simpler than this. Here is my issue. I want to make it a little more complicated but can't figure out how. I wanted to put the pages into a variable so I wouldn't have to type it out all the time like this var page1 = $(".pages:eq(0)"); var page2 = $(".pages:eq(1)"); OR var page1 = $(".pages:eq(0)",".pages:eq(1)"); This is what I thought it would be, but of course I was wrong. Can you tell me how to fix this? Link to comment https://forums.phpfreaks.com/topic/187903-help-with-jquery-array-and-links/ Share on other sites More sharing options...
trq Posted January 10, 2010 Share Posted January 10, 2010 var page1 = $(".pages:eq(0)"); var page2 = $(".pages:eq(1)"); Should work fine. What is the problem? Link to comment https://forums.phpfreaks.com/topic/187903-help-with-jquery-array-and-links/#findComment-992130 Share on other sites More sharing options...
CyberShot Posted January 10, 2010 Author Share Posted January 10, 2010 I don't know what the problem is yet, I am still working on it. It works fine if I just do $("pages:eq(0)").show(); but when I change it to var page1 = $(".pages:eq(0)"); $("page1").show(); the page disapears Link to comment https://forums.phpfreaks.com/topic/187903-help-with-jquery-array-and-links/#findComment-992133 Share on other sites More sharing options...
CyberShot Posted January 10, 2010 Author Share Posted January 10, 2010 ok, I figured it out, I had to get rid of the " marks $(page1).show(); instead of $("page1").show(); Link to comment https://forums.phpfreaks.com/topic/187903-help-with-jquery-array-and-links/#findComment-992135 Share on other sites More sharing options...
trq Posted January 10, 2010 Share Posted January 10, 2010 page1.show(); should suffice. Link to comment https://forums.phpfreaks.com/topic/187903-help-with-jquery-array-and-links/#findComment-992156 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.