Skip to content

Instantly share code, notes, and snippets.

@colmtuite
Last active August 29, 2015 13:57
Show Gist options
  • Save colmtuite/9505574 to your computer and use it in GitHub Desktop.
Save colmtuite/9505574 to your computer and use it in GitHub Desktop.
<!-- Method One -->
<span id="specific-item">Show more</span>
$('#specific-item').click(function() {
$(this).text('Show less');
});
<!-- Method Two -->
<span class="js-textEdit" data-text="Show less">Show more</span>
$('.js-textEdit').click(function() {
var oldText = $(this).text();
var newText = $(this).attr('data-text');
if ($(this).text('oldText')) {
$(this).text('newText');
} else if ($(this).text('newText')) {
$(this).text('oldText');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment