Team:UGent/Templates/Header
From 2013.igem.org
Line 38: | Line 38: | ||
<td> | <td> | ||
</html> | </html> | ||
+ | |||
+ | |||
+ | /*Script read more sections*/ | ||
+ | |||
+ | <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> | ||
+ | <script type="text/javascript"> | ||
+ | $(document).ready(function(){ | ||
+ | //Hide (Collapse) the toggle containers on load | ||
+ | $(".toggle_container").hide(); | ||
+ | //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) | ||
+ | $("p.trigger").click(function(){ | ||
+ | $(this).toggleClass("activeToggle"); | ||
+ | var nextElem = $(this).next(); | ||
+ | while(nextElem!= null) { | ||
+ | if(!nextElem.is(".toggle_container")) { | ||
+ | nextElem = nextElem.next(); | ||
+ | } | ||
+ | else { | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if(nextElem.is(".toggle_container")) { | ||
+ | nextElem.slideToggle("slow"); | ||
+ | } | ||
+ | return false; //Prevent the browser jump to the link anchor | ||
+ | }); | ||
+ | $("a.toggle_close").click(function(){ | ||
+ | var nextParent = $(this).parent(); | ||
+ | while(nextParent!= null) { | ||
+ | if(!nextParent.is(".toggle_container")) { | ||
+ | nextParent = nextParent.parent(); | ||
+ | } | ||
+ | else { | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if(nextParent.is(".toggle_container")) { | ||
+ | nextParent.slideToggle("slow"); | ||
+ | var prevElem = nextParent.prev(); | ||
+ | while(prevElem!= null) { | ||
+ | if(!prevElem.is("p.trigger")) { | ||
+ | prevElem = prevElem.prev(); | ||
+ | } | ||
+ | else { | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if(prevElem.is("p.trigger")) { | ||
+ | prevElem.toggleClass("activeToggle"); | ||
+ | } | ||
+ | } | ||
+ | return false; //Prevent the browser jump to the link anchor | ||
+ | }); | ||
+ | }); | ||
+ | </script> |
Revision as of 09:19, 29 July 2013
|
|||
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ //Hide (Collapse) the toggle containers on load $(".toggle_container").hide(); //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) $("p.trigger").click(function(){ $(this).toggleClass("activeToggle"); var nextElem = $(this).next(); while(nextElem!= null) { if(!nextElem.is(".toggle_container")) { nextElem = nextElem.next(); } else { break; } } if(nextElem.is(".toggle_container")) { nextElem.slideToggle("slow"); } return false; //Prevent the browser jump to the link anchor }); $("a.toggle_close").click(function(){ var nextParent = $(this).parent(); while(nextParent!= null) { if(!nextParent.is(".toggle_container")) { nextParent = nextParent.parent(); } else { break; } } if(nextParent.is(".toggle_container")) { nextParent.slideToggle("slow"); var prevElem = nextParent.prev(); while(prevElem!= null) { if(!prevElem.is("p.trigger")) { prevElem = prevElem.prev(); } else { break; } } if(prevElem.is("p.trigger")) { prevElem.toggleClass("activeToggle"); } } return false; //Prevent the browser jump to the link anchor }); }); </script> |