Created
August 12, 2010 14:39
-
-
Save sindresorhus/521072 to your computer and use it in GitHub Desktop.
jQuery plugin - Toggle between the current and supplied text
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
$.fn.toggleText = function(b) { | |
return this.each(function() { | |
var $this = $(this); | |
if ( !$this.data('text') ) { | |
$this.data( 'text', $this.text() ); | |
} | |
$this.text( $this.text() !== b ? b : $this.data('text') ); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment