According to the value of a dropdown menu I have to show/hide two panels. For option 'derive' and 'reject' I should show the comment panel, and just for the 'derive' panel I should also show a derivation panel. There are other
This works, but how could I refactor the code to make it shorter and more efficient without losing clarity?
$("#formTabs").on( "change", "select.actions",function(){
var parentContainer = $(this).closest("fieldset");
if(this.value == "reject" || this.value == "derive"){
parentContainer.find(".commentPanel").show();
}
// other 3 options where the panel should not show up.
else {
parentContainer.find(".commentPanel").hide();
}
// Just for the derive option, a derivation panel must be shown.
if(this.value == "derive"){
parentContainer.find(".derivationPanel").show();
} else {
parentContainer.find(".derivationPanel").hide();
}
});