2017-07-31 99 views
1

我想啓用一個按鈕的點擊事件的下拉列表,但在我的情況下,使用下面的代碼,下拉菜單啓用幾秒鐘,然後禁用aspx頁面。啓用HTML按鈕點擊事件的下拉列表

enable功能啓用下拉:

function enable() { 
    $("#ddlBranch").prop("disabled", false); 
} 

下拉列表代碼:

<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> 
     <asp:HiddenField ID="hdnClientId" runat="server" /> 
    </div> 
</div> 

按鈕單擊代碼:

<button id="btnViewHistoricData" class="btn bg-dark" onclick= "enable();" >View Historic Data</button> 

回答

0

我認爲你必須刪除 '已禁用'。

function enable() { 
    $("#ddlBranch").removeAttr('disabled'); 
} 

正確的方式禁用/啓用使用jQuery將

function enable() { 
    $("#ddlBranch").attr('disabled',false); 
} 

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-disabled

+0

我認爲這個問題是關於啓用下拉.. – Sujith

+0

它不工作,同樣的事情正在發生。啓用幾秒鐘,然後禁用。 – Prakash

+0

@Sujith編輯答案,使用第二個選項。 $( 「#ddlBranch」)ATTR( '禁用',假)。 – codeSetter

0

試試這個

$("#btnViewHistoricData").click(function() { 
     $("#ddlBranch").prop("disabled", true); 
    }); 

    <button id="btnViewHistoricData" class="btn bg-dark" >View Historic Data</button>