Skip to content

Instantly share code, notes, and snippets.

@pixelstorm
Last active May 1, 2018 00:41
Show Gist options
  • Save pixelstorm/1446739056001b59ac8f30bf072be94b to your computer and use it in GitHub Desktop.
Save pixelstorm/1446739056001b59ac8f30bf072be94b to your computer and use it in GitHub Desktop.
toggle text with btn click
jQuery(document).ready(function($) {
var show_more_btn = $("#clickme");
show_more_btn.click(function(event) {
event.preventDefault();
$( "#toggle_text_box" ).toggle( "slow", function() {
// Animation complete.
// change btn text
if (show_more_btn.text() == 'Show More') {
show_more_btn.text('Show Less');
} else {
show_more_btn.text('Show More');
}
});
});
}); // jquery noConflict
<p id="toggle_text_box" class="staff_text">The content to toggle</p>
<a id="clickme" href="#">Show more</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment