Skip to content

Instantly share code, notes, and snippets.

@davidverhage
Created August 18, 2015 21:51
Show Gist options
  • Save davidverhage/6c10eb00de3931f08ff7 to your computer and use it in GitHub Desktop.
Save davidverhage/6c10eb00de3931f08ff7 to your computer and use it in GitHub Desktop.
Show and hide element or part
<?php
/**
* A smooth way of hiding and showing certain elements using jQuery
*
*/
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("p.magic").hide();
});
$("#show").click(function(){
$("p.magic").show();
});
});
</script>
<p class="magic">Content initially hidden can be shown, or if shown can be hidden.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment