96
rated 0 times
[
101]
[
5]
/ answers: 1 / hits: 43555
/ 12 Years ago, mon, august 27, 2012, 12:00:00
I am trying to change the text of a link on click and then change back again to the original when clicked again. I am able to change the text, (from READ MORE... to CLOSE) but have been fighting to change the text back again (from CLOSE to READ MORE...)
<script language=javascript>
function changeText(idElement){
if(idElement==1){
document.getElementById('element'+idElement).innerHTML ='Close';
} else if(idElement==2){
document.getElementById('element'+idElement).innerHTML ='Close';
}
}
</script>
<a id=element1 onClick=javascript:changeText(1)>Read More...</a>
<a id=element2 onClick=javascript:changeText(2)>Read More...</a>
Thanks for any help in advance.
More From » text