Here’s some code that works on a normal page but won’t function within a bootstrap modal, any idea why this might not work?
<script type="text/javascript">
$(document).ready(function(){
$('.box').hide();
$('#dropdown').change(function() {
$('.box').hide();
$('#div' + $(this).val()).show();
});
});
</script>
<form>
<select id="dropdown" name="dropdown">
<option value="0">Choose</option>
<option value="area1">DIV Area 1</option>
<option value="area2">DIV Area 2</option>
<option value="area3">DIV Area 3</option>
</select>
</form>
<div id="divarea1" class="box">DIV Area 1</div>
<div id="divarea2" class="box">DIV Area 2</div>
<div id="divarea3" class="box">DIV Area 3</div>
Because the
$(document).ready()would have already been fired when the parent page is loaded. You should listen for bootstrap modal’sshownevent. I’m assuming you’re AJAX’ing in the modal content?