To toggle a text using jQuery you can use the following snippet.

Sample jQuery

jQuery.fn.toggleText = function(textOne, textTwo) {
	return this.each(function() {
		jQuery(this).text(jQuery(this).text() == textOne ? textTwo : textOne);
	});
};

3 thought on “How to toggle a text using jQuery”

Leave a Reply