Reputation: 475
In my application there are two dropdowns. Based on value selected in one dropdown the other dropdown(Whole div in which dropdown present) is disabled/enabled. But the other dropdown is present in another div. My problem is this is working fine in IE but not in any other browsers such as Firefox,Chrome
function rrf(id) {
if (id == 1 || id == 9) {
$("#IdDiv").children().prop('disabled', true);
}
else {
$("#IdDiv").children().prop('disabled', false);
}
}
$('select[name="DDl1"]').change(function () {
var idf = $(this).val();
rrf(idf);
.
.
.
}
Actually the two dropdowns are dropdownlists in mvc. After rendering, second dropdown list was converted to a div Like below
<div id="IdDiv" class="select2-container span4">
<a class="select2-choice" onclick="return false;" href="#">
<span>-- SELECT --</span>
<abbr class="select2-search-choice-close" style="display:none;"></abbr>
<div>
<b></b>
</div>
</a>
<div class="select2-drop select2-offscreen">
<div class="select2-search">
<input class="select2-input" type="text" autocomplete="off" tabindex="0">
</div>
<ul class="select2-results"> </ul>
</div>
<select id="DDl2" class="span4" name="DDl2" style="display: none;">
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="DDl2"></span>
</div>
Upvotes: 1
Views: 1801
Reputation: 743
Use $("#IdDiv").children().attr('disabled', 'disabled')
to disable and use $("#IdDiv").children().removeAttr('disabled')
to enable.
It will work....
Upvotes: 2