When and only when a user selects 'once a day', i.e., value 2, I want a div class called #time-formgroup
to be shown. Should the user click option 1 or 3 at anytime, for that div class to be hidden.
Currently, the div class is shown irrespective of what option they choose and stays shown!
HTML
<select id="Alert_Me" name="Alert_Me" class="form-control">
<option value="1" selected="selected">Immediately</option>
<option value="2">Once a day</option>
<option value="3">Save</option>
</select>
jQuery
$("#Alert_Me").click(function(){
var frequency = $('input[name=Alert_Me]:checked').val();
if(frequency = 2){
$('#time-formgroup').removeClass('hidden');
} else {
$('#time-formgroup').addClass('hidden');
}
});
Thank you in advanced.