Skip to content Skip to sidebar Skip to footer

How To Hide And Show Named Divs According To Enum Value?

I'm trying to hide and show divs based on a enum from a . I know this should be rather simple, but I'm very rusty on my JavaScript (and jQuery). My select form is:
$(function() {
  $('#recurrency select').on('change', function() {
    var value = this.value;
    $('#dayInterval').toggle(value == 'DAILY');
    $('#weekInterval').toggle(value == 'WEEKLY');
    $('#monthInterval').toggle(value == 'MONTHLY');
  }).change();
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="recurrency"><selectpath="recurrency"><optionvalue="-"label="--Please Select" /><optionvalue="DAILY">DAILY</option><optionvalue="WEEKLY">WEEKLY</option><optionvalue="MONTHLY">MONTHLY</option></select></div><divid="dayInterval">DAILY</div><divid="weekInterval">WEEKLY</div><divid="monthInterval">MONTHLY</div>

Post a Comment for "How To Hide And Show Named Divs According To Enum Value?"