如果打开了Thinbox,则设置主体Noscroll [英] If Thickbox is opened set body noscroll

查看:51
本文介绍了如果打开了Thinbox,则设置主体Noscroll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的JS/jQuery知识非常基础,因此我想在这里寻求帮助.

My JS/jQuery knowledge is very basic so I'm asking for a bit of help here.

我正在尝试通过Thinbox实现类似Pinterest的效果.

I'm trying to achieve something like a Pinterest effect with Thickbox.

我认为应该发生的事情是使用JS或jQuery监视Thinbox动作(无论是否存在#TB_window)并应用以下规则:

What I'm assuming should happen is using JS or jQuery to monitor Thickbox actions (if #TB_window is present or not) and apply the following rules:

  • 如果打开了Thinbox->将主体样式设置为溢出:已隐藏
  • 其他Thinbox已关闭->将主体样式设置为溢出:自动

我正在使用集成到WordPress Thinbox中的功能-add_thickbox();如果有什么区别.

I'm using the integrated into WordPress Thickbox with the function - add_thickbox(); if it makes any difference.

推荐答案

我不确定页面的结构,但以下代码应稍作调整即可

I'm unsure as to the construct of the page but the following code should fix it with a little tweaking

$(document).ready(function(){
    $('.element').click(function(){
        $('.body').css({'overflow':'hidden'});
    });
    $('.overlay, .close-button').click(function(){
        $('body').css({'overflow':'visible'});
    });
});

只需将以下内容替换为正确的类名

.element -打开thickbox的可点击链接或图像的类
.overlay -厚框后面的半透明覆盖层的类
.close-button -必要时,Thickbox上关闭按钮的类

.element - the class of the clickable link or image that opens the Thickbox
.overlay - the class of the semi-transparent overlay behind the Thickbox
.close-button - if needed, the class of the close button on the Thickbox

这篇关于如果打开了Thinbox,则设置主体Noscroll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆