Peon
Peon

Reputation: 8020

Manually close Bootstrap dropdown with multiple select

I have such a dropdown menu:

enter image description here

It works fine, but I need to add a manual Close button to it similar to this:

enter image description here

so that the Dropdown closes just like I would have clicked anywhere else on the page.

I looked at Bootstrap manuals and searched Google, but couldn't find a solution for this.

Any ideas?

Upvotes: 0

Views: 4148

Answers (1)

Ranveer
Ranveer

Reputation: 6863

You might want to try the following (put this in an on-click):

$('[data-toggle="dropdown"]').parent().removeClass('open');

Hence, your button would look like:

<button onclick="$('[data-toggle="dropdown"]').parent().removeClass('open');"> x </button>

Upvotes: 2

Related Questions