I want to disable a dropdown list on page load and enable it on button click event using JQuery. I have tried the below code but its not working. What is happening is it is disabling the list on page load, then enabling the list on button click event for one second and then again disabling the list.
$(document).ready(function () {
debugger;
if (jQuery('#btnViewHistoricData').data('clicked')) {
$("#ddlBranch").prop("disabled", false);
} else {
$("#ddlBranch").prop("disabled", true);
}
});
<div class="text-center">
<button id="btnViewHistoricData" class="btn bg-dark">View Historic Data</button>
</div>
<div class="col-md-3">
<div class="form-group m-r-sm">
<label for='rf_name'>Branch</label>
<select id="ddlBranch" class="m-b-sm w-lg form-control" onchange="ViewHistoricData()">
<option value="ALL" selected="selected">ALL</option>
</select>
</div>
btnViewHistoricDatais not pressed, the list is disabled