Thank you in advance for your help:
I really don't know much about Javascript but I'm trying to use it on my web site.
Here is the code:
function changeCategory() {
//ID#1
document.getElementById('category_106634').setAttribute("class","mind")
document.getElementById('category_106634').innerHTML="MIND"
document.getElementById('category_106634').href="http://www.voyagetobetterment.com/_blog/Voyage_to_Betterment_Blog/tag/MIND/"
//ID#2
document.getElementById('category_106446').setAttribute("class","movie")
document.getElementById('category_106446').innerHTML="MOVIE"
document.getElementById('category_106446').href="http://www.voyagetobetterment.com/_blog/Voyage_to_Betterment_Blog/tag/MOVIE/"
}
The program works fine if the ELEMENT#1 is above ELEMENT#2 in the html. If ELEMENT#2 is above ELEMENT#1 in the html, the program doesn't work. If ELEMENT#1 isn't on the page, ELEMENT#2 won't work.
How do I get this program to work regardless of whether ELEMENT1 or ELEMENT2 is in the html code or not?