I'm out of place to check this out right now, let me know if this works for you.
var menuArray = new Array();
$(function() {
$('div#nav ul li').each(function(i) {
menuArray[i] = this;
$(this).click(function() {
for (var x in menuArray)
if (x == this)
$(x).attr('class','active');
else
$(x).attr('class','inactive');
});
});
});
EDIT is fine, I was able to verify this and it works for me. Keep in mind that this should be after your HTML declaration.
$("li a").each(function(i) {
$(this).click(function() {
$(this).attr('class','selected');
$("li a").not(this).attr('class','notselected');
});
});
source
share