Created
July 20, 2013 05:50
-
-
Save spsaucier/6044016 to your computer and use it in GitHub Desktop.
User Guide - jQuery hide on heading click
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //On click of the heading-click class members or h4 elements, expand the following element. The sub-content of the headings are wrapped in <article> or <section> tags. | |
| jQuery(document).ready(function(){ | |
| $('.heading-click, h4').click(function() { | |
| $(this).next().toggle('slow'); | |
| return false; | |
| }).next().hide(); | |
| //Go to the location shown by the hash in the URL and show the element(s) containing it. | |
| function goToByScroll(id){ | |
| $('html,body').animate({scrollTop: $("#"+id).offset().top},'fast');} | |
| var hash = window.location.hash; | |
| $(hash).closest("section").show('fast'); | |
| setTimeout(function(){ | |
| goToByScroll(hash); | |
| },1000); | |
| //Display the section which is internally linked | |
| $('.internal').click(function(){ | |
| var hash = $(this).attr("href"); | |
| $(hash).closest("section").show('fast'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment