I'm finding it difficult to find examples of using jQuery, so my bad for asking such a simple question. I've got this ul:
<ul id="navLinks">
<li class="selected" id="homeNavLink"></li>
<li id="aboutNavLink"></li>
<li id="contactNavLink"></li>
...
</ul>
I'd like to write a function to change which li has the "selected" class. Here's my attempt:
function changeNavLink(selectedId) {
$("#navLinks li").each(function() {
$(this).removeClass("selected");
});
$("#" + selectedId).addClass("selected");
}
What am I doing wrong?