December 08, 2015
Toggle text back and forth from a selected phrase using this function:
function changeText(idElement) { var element = document.getElementById('learn' + idElement); if (idElement === 1 || idElement === 2) { if (element.innerHTML === 'Learn More') element.innerHTML = 'Close'; else { element.innerHTML = 'Learn More'; } } }
HTML:
<a href="javascript:void();" id="learn1" onclick="javascript:changeText(1)">Learn More</a>
Sourced here.