I want to use jQuery to open and close the dropdown. I checked this question, but it is about open only.
How to open Bootstrap dropdown programmatically
I found these two command to open it and close it.
$('.dropdown-menu').show();
$('.dropdown-menu').close();
However, how can I know the current status of the dropdown? I want click to close if it is open, and click to open if it is close.
Abderrahim Soubai-Elidrisi :
You can listen to the event :\n\n// var to be visible in the global scope\n\nvar status = false; // default hidden \n\n$('#myDropdown').on('hidden.bs.dropdown', () => status = false)\n\n$('#myDropdown').on('shown.bs.dropdown', () => status = true)\n\n\nLater you can check for the status value;",
2019-10-24T14:24:45