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
Show Background
Show Text
Modifying my answer from your other question, I would do this:
$(function() { $("#show-background").click(function () { var c = $("#content-area"); var o = (c.css('opacity') == 0) ? 1 : 0; var t = (o==1) ? 'Show Background' : 'Show Text'; c.animate({opacity: o}, 'slow'); $(this).text(t); }); });