Ever needed to use a Bootstrap dropdown as a normal HTML dropdown? Now you can!
- Automatically update the selected text of the dropdown
- onChange callback when an item of the list is selected
- Supports HTML5 data attributes
All you need to do is include this jQuery plugin into your call, create a Bootstrap dropdown and run this
$("#your-dropdown").dropdown({
onChange: function(data) {
console.log("Index: " + data.index + ", Value: " + data.value);
}
});
If you need to return a value different than the text the dropdown display, simply attach an data-value='yourvalue'
into the anchor like this
<li><a role="menuitem" tabindex="-1" href="#" data-value="your real value">Display value</a></li>
Created by Raul Riera, @raulriera