我使用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/