can I put this in a .each loop?
Hi All,
Im trying to build a menu system and each button I add Im having to
add more and more code eg:
$("#scaleButton").click(function(){
$("#scaleDiv").fadeToggle(200) ;
if($('#infoDiv').is(':visible')){
$("#infoDiv").fadeToggle(100) ;
}
if($('#saveDiv').is(':visible')){
$("#saveDiv").fadeToggle(100) ;
}
});
$("#infoButton").click(function(){
$("#infoDiv").fadeToggle(200) ;
if($('#resizerDiv').is(':visible')){
$("#resizerDiv").fadeToggle(100) ;
}
if($('#saveDiv').is(':visible')){
$("#saveDiv").fadeToggle(100);
}
});
$("#saveButton").click(function(){
$("#saveDiv").fadeToggle(200) ;
if($('#resizerDiv').is(':visible')){
$("#resizerDiv").fadeToggle(100) ;
}
if($('#infoDiv').is(':visible')){
$("#infoDiv").fadeToggle(100) ;
}
});
//
jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
so basically I have three buttons that open a div and hide the other
two, how can I put this in a loop so I dont have to keep adding if
statements?
Thanks
--