TJ *_*zie 24 jquery jquery-plugins
我正在使用Reveal jQuery插件. http://www.zurb.com/playground/reveal-modal-plugin
当我完成它时,我需要以编程方式关闭模型框,但该功能不直接包含在插件中.
根据评论页面中的戴夫,
"代码就在那里,只需要将其连接起来即可以编程方式调用."
Sil*_*der 47
如果你的模态的id是'reveal-modal',那么这一行就可以了:
$('#reveal-modal').trigger('reveal:close');
Run Code Online (Sandbox Code Playgroud)
Cor*_*ory 11
你可以通过几种方式做到这一点.
在dismissmodalclass元素上通过jquery触发单击(默认为'close-reveal-modal')
$('.close-reveal-modal').click();
Run Code Online (Sandbox Code Playgroud)
要么
将此添加到reveal.js
$.fn.hideModal = function(options){
var self = this,
modal = $(self),
topMeasure = parseInt(modal.css('top'));
$('.reveal-modal-bg').css({'display' : 'none'});
modal.css({'visibility' : 'hidden', 'top' : topMeasure});
}
Run Code Online (Sandbox Code Playgroud)
并使用
$('#your_modal_box').hideModal()
Run Code Online (Sandbox Code Playgroud)