I'm designing a website and I would like to add a certain class to a navigation element based on the document title. I currently have the following javascript. The nav elements have separate ids (the About Us nav element has the id="about" and so on)


<code>
window.onload=function(){
var docTitle = document.title;
var about = document.getElementById("about");
var advising = document.getElementById("advising")


if (docTitle = "About Us") {
about.setAttribute("class", "current");
about.setAttribute("className", "current"); // for IE which does not recognize "class"
return;
}
else {
about.setAttribute("class", "top_link");
about.setAttribute("className", "top_link"); // for IE which does not recognize "class"
}


if (docTitle = "Career Advising") {
advising.setAttribute("class", "current");
advising.setAttribute("className", "current"); // for IE which does not recognize "class"
return;
}
else {
advising.setAttribute("class", "top_link");
advising.setAttribute("className", "top_link"); // for IE which does not recognize "class"
}



}
</code>

The class change works
The problem seems to be that the if statement is true whether or not the document.title ="about" or anything else, (if I remove the return, both about us and advising elements have their class changed.

Thank you in advance