Can I check if Bootstrap Modal currently Shown / Hidden Programatically?
Like bool a = if(\"#myModal\").shown();
?
I need true/false
In offical way:
> ($("element").data('bs.modal') || {})._isShown // Bootstrap 4
> ($("element").data('bs.modal') || {}).isShown // Bootstrap <= 3
{}
is used to avoid the case that modal is not opened yet (it return undefined
). You can also assign it equal {isShown: false}
to keep it's more make sense.