I'm trying to close a Bootstrap 3 dropdown if it's open.
I thought about using $( '#mydropdown' ).dropdown( 'toggle' )
but that doesn't help because if the dropdown is currently closed I don't want it to toggle open.
How can I modify my code so that it checks to see if the dropdown is open before executing the toggle method?
if ( $( '#mydropdown' ).hasClass( 'open' ) )
$( '#mydropdown' ).removeClass( 'open' );
This is the solution I went with. It simply removes the .open
class if the dropdown has it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments