featherlight.js background & close button css?
featherlight.js background & close button css?
我想使用一个简单的js来停用和激活html "body"
的溢出,如下所示:
$('.my_link').click(function(){
$('body').css('overflow-y', 'hidden');
});
$('.featherlight_background & featherlight_close_button').click(function(){
$('body').css('overflow-y', 'scroll');
});
但是我没有找到"featherlight_background"和"featherlight_close_button"的css名称-...".featherlight:last-of-type"和".featherlight-close-icon";(不起作用。
这就是我使用的脚本:羽毛光
有人可以帮助我吗?
我建议使用Featherlight的配置选项来解决它,而不是将jQuery事件添加到其元素中。
查看 Featherlight 文档的配置部分,似乎您可以定义一个在灯箱打开或关闭时要调用的函数,请参阅 beforeOpen
、afterOpen
、 beforeClose
和 afterClose
。
您可以使用元素上的数据属性定义这些函数,例如 data-featherlight-before-open
,通过覆盖全局默认值,例如 $.featherlight.defaults. beforeOpen
,或者将它们作为参数添加到您的羽毛灯调用中,例如 $.featherlight('#element', { beforeClose: ... });
我添加了一个小示例,该示例使用全局配置方法在打开灯箱时将文本Lightbox is closed
更改为Lightbox is open
。
$(function() {
$('#btn').featherlight('#lightbox');
$.featherlight.defaults.beforeOpen = setLightboxOpen;
$.featherlight.defaults.afterClose = setLightboxClosed;
});
function setLightboxOpen() {
$('#text').text('Lightbox is open');
}
function setLightboxClosed() {
$('#text').text('Lightbox is closed');
}
.hidden {
display: none;
}
<link href="https://cdn.rawgit.com/noelboss/featherlight/master/release/featherlight.min.css" rel="stylesheet"/>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://cdn.rawgit.com/noelboss/featherlight/master/release/featherlight.min.js"></script>
<button id="btn">Open lightbox</button>
<p id="text">Lightbox is closed</p>
<div id="lightbox" class="hidden">
Lightbox contents
</div>
相关文章:
- javascript button target_blank?
- 获取打开jquery对话框的button的id
- javascript button ajax and php
- 模拟<按钮>在<asp:button>
- CKJustify和Color Button插件之间的不兼容
- jQuery[button.class]未检测到用按钮追加行
- Webiopi multiple button css
- button.单击两次删除附加操作后不工作
- 如何停止向上滚动<按钮dojoType=“;dijit.form.Button”;type=“;提交”/>在
- getDocument by id/get input text from button dons'不起作用
- javascript页面加载发生在Button Click上
- react native renderRow with button:将rowData推到按钮函数
- ASP/C#-未触发UpdatePanel和Button OnClick事件
- 如何通过 Button 在 materializecss 中发送值
- 使用 javascript 创建的窗口在使用 window.close() 时不会在卸载之前触发
- window.close();在Chrome和Firefox中不起作用
- 节点.js集群模块不会在 http 上释放套接字/端口.Server.close().
- Jqueryui dialog(“close”) 结束当前的 JavaScript 线程
- HTML Button and href prbolem
- featherlight.js background & close button css?