I am setting up a page to show/hide content by clicking on a menu item, using jquery. In each case I also hide the other divs. The following code seems sensible to me, but I guess I'm missing something because it works inconsistently. Sometimes clicking on a menu item works as expected and other times it does not. Something to do with hiding divs even when they are hidden?
$(document).ready(function() {
$('#commercial-menu-item').click(function() {
$('#other').toggle();
$('#intuito').hide();
$('#pro-bono').hide();
$('#all').hide();
});
$('#other-menu-item').click(function() {
$('#other').toggle();
$('#commercial').hide();
$('#pro-bono').hide();
$('#all').hide();
});
$('#pro-bono-menu-item').click(function() {
$('#pro-bono').toggle();
$('#other').hide();
$('#commercial').hide();
$('#all').hide();
});
$('#all-menu-item').click(function() {
$('#all').toggle();
$('#other').hide();
$('#pro-bono').hide();
$('#commercial').hide();
});
});
This is the first real thing I've done with jquery, so it probably shows...