I am using jQuery to display content on a website based upon the menu item selection. Each menu item has an number attached to it that matches the content div container.
$(".main-cat").hover(function() {
$(this).parent().find("div.arrow-right").remove();
$(this).after('<div class="arrow-down"></div>');
$(this).addClass('selected');
$(this).css('cursor', 'pointer');
},
function() {
$(this).removeClass('selected');
$(this).parent().find("div.arrow-down").remove();
});
$("#sidebar div").click(function() {
$("#real_0").hide();
$(".content_sub").hide();
var menuClass = $(this).attr('class');
menuClassP = menuClass.split(" ");
$("#real_" + menuClassP[1]).fadeIn('slow');
});
I am trying to add a function that will highlight only the menu item that corresponds to the currently *active* content.
What's the best way to write this? And can my current code be made cleaner?
relattribute to hold the class that you need. Rather than splitting the string. It would be a bit more clean - brenjt