Disable Twitter Bootstrap Button Group

前端 未结 4 455
萌比男神i
萌比男神i 2021-01-17 20:06

I have a button group on a page that is used for a selection. After the selection is made I want the button group to still be visible so the user can see the selection they

4条回答
  •  渐次进展
    2021-01-17 20:54

    You can use the disabled attribute on the buttons to disable their use, as described in the Bootstrap docs. It essentially involves adding the attribute 'disabled' to the button element, like so;

    You can use jQuery to dynamically add this attribute once you've done whatever you want to do

    $('.btn-group-vertical button').attr('disabled','disabled');
    

    And if you wanted to re-enable it

    $('.btn-group-vertical button').removeAttr('disabled');
    

    Bear in mind that the above would apply this behaviour to all button groups with this class name. If you don't want that you'll need to add an ID to the btn group div and use that in the jQuery selector.

提交回复
热议问题