How to check if a bootstrap modal is open or closed using jquery?

Can anyone tell me how to check if a bootstrap model is open or closed? If the modal is opened then I want to dynamically generate content inside the modal.

You can use this code below for checking if the model is shown or hidden.


It will return true if the modal is shown or false if the modal is closed.

If I understand your question correctly, you need a bootstrap show event. When the modal is opening you want to generate the content dynamically right?

$('#myModal').on('', function (e) {
    console.log('modal opened');
    // Your code goes here

Here are a few more useful events.

Please check the bootstrap office website for more details.