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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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(); Quote Link to comment Share on other sites More sharing options...
trq Posted January 10, 2010 Share Posted January 10, 2010 page1.show(); should suffice. Quote Link to comment 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.