[英]Hide modal window javascript
因此,为了显示此模式,我有以下代码:
<button type="button" onclick="openModal(); return false;">A button</button>
和为此的JavaScript是:
<script type='text/javascript'>
function openModal(a)
{
$.modal({
content: 'Some content here',
title: 'a title',
maxWidth: 500,
});
win.closeModal();
}
</script>
我需要一个将其隐藏的函数。 谁能给我一些有关如何执行hideModal()函数的建议,该函数将在我单击屏幕上的任意位置时隐藏模式?
在浏览器窗口中以模式打开的情况下,使用浏览器的控制台尝试
var modal;
function btnsModal() {
var btns = {
'Close': function (win) {
modal.closeModal()
}
}
return btns;
}
function openModal(oLink, content) {
var btn = btnsModal();
modal = $.modal({
buttons: btn
});
}
您可以向对话框添加“打开”事件,然后在单击侦听器上绑定到该事件,如果您单击任意位置,它将关闭对话框---
open: function(){
jQuery('.ui-widget-overlay').bind('click',function(){
jQuery('#ID_of_ur_dialog').dialog('close');
})
}
为了隐藏效果,您可以使用“隐藏”选项---
hide: "highlight"
这太蠢了...
我用css中的display none修复了这个问题。。。事实证明我没有把它弄成槽。。。我添加了display none和一个JS事件,该事件在单击页面上的其他任何地方(模态除外)时都会触发CSS。
非常感谢您的投入! 真的很感激!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.