Bootstrap 3 Modal: how to check if modal is open or closed using jquery/javascript

后端 未结 5 1088
陌清茗
陌清茗 2021-02-01 21:15

Can anyone please tell me how to check bootstrap 3.0 modal status, is it open or closed using jQuery or javascript. I used following code but it works when you have opened a mod

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 21:21

    try checking:

    if($("#addMemberModal").data('modal') && $("#addMemberModal").data('modal').isShown ) {
        console.log("Modal is open");
    }
    

    or

    if( $('#addMemberModal').hasClass('in') ) {
        console.log("Modal is open");
    }
    

提交回复
热议问题