I need to open a Bootstrap dropdown menu via JavaScript. This answer suggests adding and removing the open
class, but when I try that, nothing happens. Adding a dif
Your main problem is that you aren't stopping the click event from propagating to the document
. Bootstrap sets an event listener on the document
that closes dropdowns.
$('input').on('click', function (e) {
e.stopPropagation();
$(this).next('.dropdown').find('[data-toggle=dropdown]').dropdown('toggle');
});
jsFiddle - http://jsfiddle.net/8p6Wd/2/