Link here: bootstrap button dropdowns
I'd like to disable this button dropdown, i added disabled
class to <a>
but the dropdown can still be opened by clicking the dropdown button. Any ideas?
We use <select> and <option> elements to create a drop-down list and use disabled attribute in <select> element to disable the drop-down list element. A disabled drop-down list is un-clickable and unusable. It is a boolean attribute.
To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.
As all Twitter Bootstrap users know, the dropdown menu closes on click (even clicking inside it). To avoid this, I can easily attach a click event handler on the dropdown menu and simply add the famous event. stopPropagation() .
Dropdown (select element) is always read only. User do not edit it. User can select any of the option of its own chice. Unlike other html elements, it dont have a attribute which can make the element readony and prevent users to change its value.
Add disabled
class to the button...
<div class="btn-group"> <button class="btn btn-primary dropdown-toggle disabled" data-toggle="dropdown">Action <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li class="divider"></li> <li><a href="#">Separated link</a></li> </ul> </div>
That works when editing via bootstraps site. I did notice that they're not using the anchor like their example.
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Yeah you can do it this way:
$('.dropdown-toggle').data('toggle', '');
This works only when it gets this property: data-toggle="dropdown"
, You can either change the dropdown
to ''
blank one.
Or you can try and remove the attr of data-toggle
$('.dropdown-toggle').removeAttr('data-toggle');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With