我想在加載頁面時禁用下拉列表並使用JQuery在按鈕單擊事件上啓用它。我試過下面的代碼,但它不工作。發生的情況是禁用頁面加載列表,然後啓用按鈕單擊事件列表一秒鐘,然後再次禁用列表。想要禁用頁面加載時的下拉列表,並在HTML中的按鈕單擊事件中啓用它
$(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>
如果你擺脫了其他塊,這有幫助嗎? – user3080953
我想禁用頁面laod上的列表並啓用它按鈕單擊,這就是爲什麼我選擇瞭如果條件 – Prakash
每當'btnViewHistoricData'沒有按下時,列表被禁用 – user3080953