Sar*_*ara 5 javascript jquery twitter-bootstrap bootstrap-modal bootstrap-4
我想检查某个模式是否已经打开,我尝试过这种方法(bootstrap-4)但对我不起作用(即使对话框打开也总是给出“false”)
$('#myModal').is(':visible');
$('#myModal').data('bs.modal').isShown ;
$('#myModal').hasClass('in');
Run Code Online (Sandbox Code Playgroud)
我检查了模态 classList ,在它在屏幕上可见后没有任何新类添加到我的模态中
我不想要事件处理程序,因为我不想跟踪状态,我只想检查对话框之前是否通过其他功能打开过
当引导模式(V4中)表示,据我可以看到,三件事情发生在DOM,模态得到命名为两类褪色和显示分别与样式属性显示以块(和mybe其他类似的填充...) 并且body标签获得一个名为modal-open的类。所以实际上你所要做的就是检查其中一件事情,我建议检查节目类的现有内容。
$('#exampleModal').hasClass('show'); // return true if the modal is open
Run Code Online (Sandbox Code Playgroud)
或者
$('body').hasClass('modal-open');
Run Code Online (Sandbox Code Playgroud)
$('#exampleModal').hasClass('show'); // return true if the modal is open
Run Code Online (Sandbox Code Playgroud)
.show如果模态已通过 Bootstrap JS 显示,则您的模态将具有该类,因此如果您想查看模态当前是否打开,您可以检查$('#myModal').hasClass('show').
| 归档时间: |
|
| 查看次数: |
7197 次 |
| 最近记录: |