Having some trouble with more than one switch statement at a time:
$(document).ready(function(){
$('#menu').children('span').click(function(){
whichsub = $(this).attr('id');
switch (whichsub) {
case 'menu1':
$('#submenu').load('menus/submenu1.html');
break;
case 'menu2':
$('#submenu').load('menus/submenu2.html');
break;
};
if ( $('#submenu').css('left') !== '150px' ) {$('#submenu').animate({left: '150px'}, 300);}
});
$('#submenu').children('span').click(function(){
var whichcon = $(this).attr('id');
switch (whichcon) {
case 'submenu1':
$('#demopanel').load('content/profile.html');
break;
case 'submenu2':
$('#demopanel').load('content/portfolio.html');
break;
};
if ( $('#demopanel').css('marginLeft') !== '300px' ) {$('#demopanel').animate({marginLeft: '300px'}, 1000);}
});
});
The top switch changes the submenu and conditionally slides it out, the bottom changes the content ("#demopanel"). Each works on it's own, but when I have both enabled, the second fails to work -- it acts as if the script has stopped since an alert placed after $('#submenu').children('span').click(function(){
returns nothing.
Any ideas where this might be going wrong? Do I need to unbind something?
Thanks.