Bootstrap 3 Modal:如何使用jquery/javascript检查模式是打开还是关闭 [英] Bootstrap 3 Modal: how to check if modal is open or closed using jquery/javascript

查看:120
本文介绍了Bootstrap 3 Modal:如何使用jquery/javascript检查模式是打开还是关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何检查bootstrap 3.0模态状态,它是使用jQuery还是JavaScript打开还是关闭.我使用了以下代码,但是当您一次打开模态时它可以工作,否则会给数据带来不确定的错误.

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 modal for one time otherwise gives data undefined error.

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

推荐答案

您还可以像这样使用直接jQuery:

You can also use straight jQuery like this:

$('#myModal').is(':visible');

这篇关于Bootstrap 3 Modal:如何使用jquery/javascript检查模式是打开还是关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆