Camillia
asked on
jQuery code works but want to make sure this is a good way of hiding/displaying
As part of my code clean up of what the ex-developer has, I want to make sure this is good to leave as is or if there's a better (I'm looking for mainatable code) way of doing this
1. There are divs with classes and these divs are hidden/displayed based on what the user selects from a dropdown. I can leave it as is, if there isn't a cleaner way
2. A change function is called and the divs are hidden and displayed like this
1. There are divs with classes and these divs are hidden/displayed based on what the user selects from a dropdown. I can leave it as is, if there isn't a cleaner way
2. A change function is called and the divs are hidden and displayed like this
$(document).on('change', '#scheduleArea .schedule select.typeSelector', function () {
.....
var scheduleDiv = $(this).parents('.schedule');
...
var classToDisplay = '';
switch (value) {
case 'O':
classToDisplay = 'scheduleOnce';
break;
case 'D':
classToDisplay = 'scheduleDaily';
break;
case 'W':
classToDisplay = 'scheduleWeekly';
break;
case 'M':
classToDisplay = 'scheduleMonthly';
break;
default:
break;
}
if (classToDisplay != '') {
$('.' + classToDisplay, scheduleDiv).removeClass('hidden');
if (value != 'O') $('.endDate', scheduleDiv).removeClass('hidden'); // Don't display end date for Once runs
$('.export', scheduleDiv).removeClass('hidden');
$('.emailAddresses', scheduleDiv).removeClass('hidden');
$('.timeZone', scheduleDiv).removeClass('hidden');
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Chris. Let me take a look
ASKER
thanks, as always.
ASKER