簡體   English   中英

根據下拉選擇啟用和禁用按鈕。 -引導程序3

[英]Enable and Disable button based on drop-down selection. - Bootstrap 3

我有一個名為“更新”的按鈕,在從下拉菜單中選擇一個選項之前,我希望將其禁用。

到目前為止,我已禁用該按鈕:

$('.btn-update').prop('disabled', true);

這是我對按鈕和下拉菜單的標記:

<div class="col-md-12 tableContainer">
        <div class="panel-heading import-song-panel text-center">
            <div class="panel-title">
                <ul class="list-inline">
                    <li class="pull-right">
                        <div class="dropdownContainer btn-group text-right">
                            <button type="button" class="btn btn-primary br2 btn-md fs12 dropdown-toggle table-btn" id="table-actionbtn" data-toggle="dropdown" aria-expanded="false">
                                Select Status
                                <span class="caret ml5"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                <li>
                                    <a href="#" data-container="body" data-toggle="tooltip" title="Accept & Send" data-rowhover="editTableRow">Accept &amp; Send</a>
                                    <a href="#" data-container="body" data-toggle="tooltip" title="Accept" data-rowhover="editTableRow">Accept</a>
                                    <a href="#" data-container="body" data-toggle="tooltip" title="Reject" data-rowhover="editTableRow">Reject</a>
                                </li>
                            </ul>
                        </div>
                    </li>
                </ul>

            </div>
        </div>
    </div>

    <div class="col-md-12 text-right">
        <div class="panel-heading import-song-panel text-right">
            <input type="button" class="btn btn-primary" id="js_CancelForm" value="Cancel" />
            <input type="submit" class="btn btn-success btn-update" id="js_SubmitForm" value="Update" />
        </div>
    </div>

只有當從下拉菜單中選擇狀態時,誰能向我展示如何啟用按鈕。

您可以在下拉選項上添加onclick事件。

<a href="#" data-container="body" onclick="enableButton()" data-toggle="tooltip" title="Accept & Send" data-rowhover="editTableRow">Accept &amp; Send</a>

並在點擊事件上調用函數

function enableButton(){
 $('.btn-update').prop('disabled', false);
}

您可以將一個類添加到下拉選項中,還可以添加一個click事件。 喜歡:

$('.optclick').click(function(){
$('.btn-update').prop('disabled', false);
e.preventDefault();

});

https://jsfiddle.net/Lz8sxmqm/10/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM