saquery.com
a web developer' s kung fu…
jQuery toggleText function
Categories: jQuery
This is a simple function to toggle text contents of an HTML element with jQuery. It should be easy to equip the toggleText methode with an array of strings.
		
/*
 * jQuery.toggleText Plugin.
 * Copyright (c) saquery.com
 * Licensed under MIT - http://www.opensource.org/licenses/MIT
 */

$.fn.toggleText = function(txt){
	return this.each(function(){		  
		var _=$(this),_current=_.text(),_txt=txt;
		if ( _current === txt){ _txt=_.data('oldvalue'); } else { _.data('oldvalue',_current); };
		_.text(_txt);
	});
};

Vote this page

Tags:,

Leave a Reply