在HTML中启用按钮单击事件的下拉列表

时间:2017-07-31 09:03:42

标签: c# html asp.net

我想在按钮的click事件上启用下拉列表,但在我的情况下使用以下代码,下拉列表启用几秒钟,然后在aspx页面中禁用。

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>

2 个答案:

答案 0 :(得分:0)

我认为您已删除'已停用'。

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

使用jQuery禁用/启用的正确方法

{{1}}

enter image description here

答案 1 :(得分:0)

试试这个

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

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