我一直在尝试让 Greasemonkey 通过单击“x”按钮来关闭模式。这是该页面的代码。
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onClick="window.location.reload()">x</button>
我尝试使用 document.querySelector('.close').click()
但无济于事。我哪里出错了?
相关页面正在运行 javascript 和 ajax。
最佳答案
代码看起来像 Bootstrap 模式,因此查找主容器 ID 或类名称并使用以下代码。
$('#modalID').modal('hide');
关于javascript - 关闭弹出模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23547716/