I have some HTML and JavaScript to show and hide a div based on a selection in a dropdown list.
The JavaScript looks as follows:
$('.type-of-display-group').hide();
$('#six-graphs').show();
$('#display-type').change(function () {
$('.type-of-display-group').hide();
$('#' + $(this).val()).show();
});
The HTML looks as follows:
<select class="form-control" id="display-type">
<option value="six-graphs">Six graphs</option>
<option value="sliderFrame">Carousel</option>
</select>
<div id="six-graphs" class="type-of-display-group">
[CODE FOR SIX GRAPHS]
</div> <!-- End six graphs display-->
<!-- The div for the carousel-->
<div id="sliderFrame" class="type-of-display-group">
[CODE FOR CAROUSEL]
</div><!-- End of carousel -->
See this Fiddle to see the code in action.
So the code works in Firefox, but it does not work in IE8. What happens is that both the div's are displayed on top of each other (and I see the broken signal on the lower left corner). When I debug the script with F12 and then use the debugger the code suddenly works...
Does anyone have another way of using the show()
and hide()
jQuery functions so that I can use this code in IE8?