Forum Moderators: open
I was wondering if it is possible to do the following using js.:
I want to place a link on a webpage that triggers a switch.
I.e. the word 'hello' is written into the page when it is first loaded. Then when you press a link the word 'hello' switches to 'goodbye'
I need this feature to work without the intire page being reloaded.
It's probably easy - well if you know the answer, that is.
Any help would be highly apreciatet.
cheers
1. Put your word into an element of it's own. A span is good, as it doesn't have to have any stylistic effect.
2. Give the span an id: <span id="swap">hello</span>
3. Your link (doesn't need to be a link BTW. Use onclick on any element):
<a href="#" onclick="document.getElementById('swap').innerHTML='goodbye'">