我可以检查Bootstrap Modal当前是否以编程方式显示/隐藏吗?
就像bool a = if("#myModal").shown();
一样?
我需要true/false
发布于 2013-10-30 13:46:17
alert($('#myModal').hasClass('in'));
如果modal是打开的,它将返回true
发布于 2013-10-30 15:42:17
文档中给出了最好的方法
$('#myModal').on('shown.bs.modal', function () {
// will only come inside after the modal is shown
});
发布于 2015-02-11 20:38:30
这是一个古老的问题,但不管怎样,我在这里使用了一些东西,以防有人正在寻找相同的东西
if (!$('#myModal').is(':visible')) {
// if modal is not shown/visible then do something
}
https://stackoverflow.com/questions/19674701
复制相似问题