Last active
August 29, 2015 13:57
-
-
Save colmtuite/9505574 to your computer and use it in GitHub Desktop.
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
<!-- 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