-
-
Save jentanbernardus/2943713 to your computer and use it in GitHub Desktop.
Simple jQuery Toggle Javascript snippet
This file contains 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
<a href="#" id="toggleButton">Click Here</a> | |
<div id="toggleSection"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> | |
</div> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> | |
<script type="text/javascript" src="js/toggle.js"></script> |
This file contains 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
$(document).ready(function() { | |
$('.toggleButton').click(function() { | |
if ($('.toggleSection').is(":hidden")) | |
{ | |
$('.toggleSection').slideDown("slow"); | |
} else { | |
$('.toggleSection').slideUp("slow"); | |
} | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the html you're giving them IDs; In JS you're calling Classes