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
Main Text (function() { var mainText = $('.mainText').text(), altText = 'Alt Text'; $('#changeText').on('click', function(){ $(this).toggleClass('altText'); $('.mainText').text(mainText); $('.altText').text(altText); }); })();