mrbean Posted June 18, 2012 Share Posted June 18, 2012 hello, Let´s get straight to the point. I have a couple of div´s <div id="container"> <div id="page1"> <div id="page2"> <div id="page3"> <div id="page4"> <div id="page5"> <div id="page6"> If someone gets to page like 5 through my js code, I only want to show page5 and container. Soo, in css I want to select everything except container and page5. I can't manually type in the pages because, there will be adding daily more pages. note: if my english is not right or see some grammer errors, please correct me. kind regards, "mrbean" Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted June 19, 2012 Share Posted June 19, 2012 CSS will not do this. Javascript or PHP could. You'd need some way to tell the current page which page number it was, then you could show (display:block;) it while leaving the other div's as display:none; Quote Link to comment Share on other sites More sharing options...
mrbean Posted June 19, 2012 Author Share Posted June 19, 2012 It will be an interactive site, so javascript is how I want to do it. Can you show me an example of how I could fix this problem? btw Soo, in css I want to... is Soo, in javascript(with jquery) I want to... Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted June 19, 2012 Share Posted June 19, 2012 depends on how you are indicating what page you are on. Quote Link to comment Share on other sites More sharing options...
haku Posted June 29, 2012 Share Posted June 29, 2012 You can do this by adding an ID to your <body> tag, indicating what page you are on: Ex: page 1 body tag <body id="page_1"> page 5 body tag <body id="page_5"> Then you give each of the containers a common class name: <div id="page1" class="pagediv"> <div id="page2" class="pagediv"> <div id="page3" class="pagediv"> <div id="page4" class="pagediv"> <div id="page5" class="pagediv"> <div id="page6" class="pagediv"> Then you can set your CSS up like this: .pagediv { display:none; } #page_1 #page1 { display:block; } #page_2 #page2 { display:block; } #page_3 #page3 { display:block; } #page_4 #page4 { display:block; } #page_5 #page5 { display:block; } By doing this, you hide all the .pagedivs, and show #page1 on the div that has a body#page_1, #page2 on body#page2, and so on. 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.