replace a buch of show/hide with switch/case in javascript
Posted
by Adam
on Stack Overflow
See other posts from Stack Overflow
or by Adam
Published on 2010-03-28T21:19:49Z
Indexed on
2010/03/28
21:23 UTC
Read the original article
Hit count: 308
Page has menu items that would replace a 'div id=foo_(current menu item)' with 'div id=foo_(selected menu item)' in 'div class=foo'
Here's what I've got, and try to keep your breakfast down...
$('#t1').click(function() {
$('#attorney').show();
$('#insurance,#financial,#estate,#trust,#death').hide();
});
$('#t2').click(function() {
$('#insurance').show();
$('#attorney,#financial,#estate,#trust,#death').hide();
});
$('#t3').click(function() {
$('#financial').show();
$('#attorney,#insurance,#estate,#trust,#death').hide();
});
$('#t4').click(function() {
$('#estate').show();
$('#attorney,#insurance,#financial,#trust,#death').hide();
});
$('#t5').click(function() {
$('#trust').show();
$('#attorney,#insurance,#financial,#estate,#death').hide();
});
$('#t6').click(function() {
$('#death').show();
$('#attorney,#insurance,#financial,#estate,#trust').hide();
});
© Stack Overflow or respective owner