disable bootstrap select option using javascript

前端 未结 5 1124

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 10:58

    As described here, you need to re-render the select picker after changing the disabled property of an option.

    This should do the trick: (JSFiddle)

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

提交回复
热议问题