How to toggle HTML text of an anchor tag using jQuery? I want an anchor that when clicked the text alternates between Show Background & Show Text
Use html() to toggle HTML content. Similar to fflyer05's code:
$.fn.extend({
toggleText:function(a,b){
if(this.html()==a){this.html(b)}
else{this.html(a)}
}
});
Usage:
Toggle me!
Fiddle: http://jsfiddle.net/DmppM/