There are several questions about this on SO (1,2,3,4), but all are extremely old and unhelpful.
This code works flawlessly in Chrome & Firefox, but how can I get Internet Explorer to cooperate? Right now in IE, you click a select option and it does nothing. Some have proposed .click() but that doesn't establish whether or not there was a change in the selected option, even though I couldn't seem to get .click() to work in IE11 anyway.
Any suggestions?
$(document).ready(function($) {
$('.block-webform').hide();
$('#contact-select option[value="select"]').attr("selected", "selected");
$('#contact-select').change(function() {
$('.block-webform').slideUp(600);
$('#' + $(this).val()).slideDown(600);
});
});
.block-webform {
height: 30px;
margin: 30px;
background: lime;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="contact-select">
<option value="select" selected="selected">- Select Reason for Contact -</option>
<option value="block-webform-client-block-1" name="1">General Question</option>
<option value="block-webform-client-block-2" name="2">Update Information</option>
<option value="block-webform-client-block-3" name="3">Question About Order</option>
</select>
<div id="block-webform-client-block-1" class="block-webform">General Question</div>
<div id="block-webform-client-block-2" class="block-webform">Update Information</div>
<div id="block-webform-client-block-3" class="block-webform">Question About Order</div>
Fiddle: https://jsfiddle.net/9h7jLe64/1/