Last active
May 1, 2018 00:41
-
-
Save pixelstorm/1446739056001b59ac8f30bf072be94b to your computer and use it in GitHub Desktop.
toggle text with btn 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
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