I have a menu list, as I scroll over the menu list the related divs are shown or hidden. This works fine with the following:
$('.ov_menu li').mouseover(function(){
var div_show = ($(this).parent().attr('href'));
$('.homepage_display').hide();
$(div_show).show();
$('.ov_menu li').css('background-color','#ffffff')
$(this).css('background-color','#cceffc');
return false;
});
What is the most efficient way to display the relevant div when I click on the menu item, without having to type out the above code again (but using the click event rather than the mouseover event).
Markup:
<div class="ov_menu">
<ul>
<a href="#new"><li>Create New Check</li></a>
<a href="#in_progress"><li>In Progress Checks</li></a>
<a href="#completed"><li>Completed Checks</li></a>
<a href="#archived"><li>Archived Checks</li></a>
</ul>
</div>
<div class="homepage_display" id="new">
Content
</div>
<div class="homepage_display" id="in_progress">
Content
</div>
<div class="homepage_display" id="completed">
Content
</div>
<div class="homepage_display" id="archived">
Content
</div>