disable bootstrap select option using javascript

前端 未结 5 1159

I attempt to disable my specific bootstrap select option using javascript.

I know how to disable \"normal select option\", but when using bootstrap select it just di

5条回答
  •  灰色年华
    2021-01-14 11:06

    Using render as mentioned above is no longer the working. As written in their Docs refresh is the method to use after changing options.

    To programmatically update a select with JavaScript, first manipulate the select, then use the refresh method to update the UI to match the new state. This is necessary when removing or adding options, or when disabling/enabling a select via JavaScript.

    function disableDropdown(){
        var selectobject;
        selectobject = document.getElementById("dropdownBranch").getElementsByTagName("option");
        selectobject[3].disabled = true;
        $('#dropdownBranch').selectpicker('refresh');
    }
    

提交回复
热议问题