javascript - 单击背景时禁用关闭弹出窗口

标签 javascript jquery lightbox

我使用featherlight.js作为灯箱。当它打开并单击它的背景时,它会关闭弹出窗口。我需要禁用此功能。我注意到这个js中有closeTrigger选项,但不知道如何使用它。

最佳答案

我建议不要单独编写 JavaScript 代码片段,因为您已经使用“数据”属性来初始化灯箱。

根据提供的文档,您可以在标记本身中设置 data-featherlight-close-on-click="false" 来实现相同的目的。

fiddle - http://jsfiddle.net/ylokesh/c5pq5bs1/2/

HTML

<a class="btn btn-default" href="#" data-featherlight-close-on-click="false" data-featherlight="#fl1">Default</a>
<div class="lightbox" id="fl1">
    <h2>Featherlight Default</h2>
    <p>
        This is a default featherlight lightbox.<br>
        It's flexible in height and width.<br>
        Everything that is used to display and style the box can be found in the 
    </p>
    <a href="https://github.com/noelboss/featherlight/blob/master/src/featherlight.css">featherlight.css</a> file which is pretty simple.
</div> 

使用此选项,您将无需编写单独的脚本 block 来启用此功能。

关于javascript - 单击背景时禁用关闭弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30938584/

相关文章:

javascript - jQuery 导航轮播

javascript - FancyBox onload show 无法正常点击

html - 使用 Lightbox 2 对图像的 CSS 悬停效果

javascript - Quickblox 字符串化通知

javascript - forever node.js - 监视文件更改的目录

javascript - 如果 location.hash 等于 jquery 中的某个值,则执行某些操作

javascript - prettyPhoto 一页上的多个画廊

javascript - 如何在 javascript 中编写 if else 语句

javascript - 设置特定日期的默认值

javascript - 在 jQuery Mobile 1.4.2 中获取加载的页面