如果“子表"被隐藏,则隐藏“父Div"(显示:无) [英] Hide Parent Div if Child Table is hidden (display: none)

查看:95
本文介绍了如果“子表"被隐藏,则隐藏“父Div"(显示:无)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在StackOverflow和Google上进行搜索,发现了一些我认为可行的想法,但似乎无济于事!

I've tried searching all over StackOverflow and Google and I've found ideas that I thought would work but nothing seems to help!

我正在使用SugarCRM Professional 6.5.5,如果使用jQuery隐藏了子表的父div(显示:无),我试图隐藏子表的父div,但是我运气不佳.

I'm working in SugarCRM Professional 6.5.5 and I'm trying to hide the parent div of a child table if the table is hidden (display: none) using jQuery but I'm not having much luck.

例如,在下面的代码中,我试图隐藏<div id="detailpanel_5" class="detail view detail508 expanded">,因为子表<table id="LBL_EDITVIEW_PANEL6" class="panelContainer" cellspacing="0" style="overflow: hidden; height: 0px; display: none;">被隐藏了.

For example, in the code below I'm trying to hide <div id="detailpanel_5" class="detail view detail508 expanded"> because the child table <table id="LBL_EDITVIEW_PANEL6" class="panelContainer" cellspacing="0" style="overflow: hidden; height: 0px; display: none;"> is hidden.

我能够使用$('#LBL_EDITVIEW_PANEL6').parent().hide();成功隐藏父div,但问题是每个页面上都有很多表隐藏,并且视图是动态的-并非每个页面都隐藏了相同的表.

I am able to successfully hide the parent div with $('#LBL_EDITVIEW_PANEL6').parent().hide(); however the problem is that there are a lot of tables hidden on each page, and the view is dynamic -- not every page will have the same tables hidden.

所以我要jQuery要做的是在加载后浏览页面,并只隐藏被隐藏的子表的父div.

So what I want jQuery to do is go through the page after it is loaded and hide only the parent div of the child table that is hidden.

我尝试使用类似以下内容的内容:$(":hidden").parent().hide();搜索任何隐藏的元素,但是隐藏了整个页面(屏幕是完全白色的).我已经尝试过$("table:hidden").parent().hide();,但是似乎什么也没做.

I've tried using something like: $(":hidden").parent().hide(); to search for any hidden elements but that hides the entire page (the screen is completely white). I've tried $("table:hidden").parent().hide(); but that doesn't seem to do anything.

很抱歉,如果我没有提供任何有助于答案的细节.如果需要的话,我将很乐意提供更多信息.希望这是我忽略的很小的东西.

Apologies if I left out any details that would be needed to help with an answer. I will be glad to offer any more info if it is needed. Hopefully it's something very small I am overlooking.

下面是HTML的一小段:

A small snippet of the HTML is below:

<div class="yui-content">
    <div id="tabcontent0">
        <div id="detailpanel_1" class="detail view detail508 ">
        <div id="detailpanel_2" class="detail view detail508 expanded">
        <div id="detailpanel_3" class="detail view detail508 expanded">
        <div id="detailpanel_4" class="detail view detail508 expanded">
            <h4>
            <table id="LBL_EDITVIEW_PANEL7" class="panelContainer" cellspacing="0">
            <script type="text/javascript">
        </div>
        <div id="detailpanel_5" class="detail view detail508 expanded">
            <h4>
            <table id="LBL_EDITVIEW_PANEL6" class="panelContainer" cellspacing="0" style="overflow: hidden; height: 0px; display: none;">

推荐答案

$(":hidden")也返回<head><style><script>等元素.他们的父母是<html>文档本身.因此,$(":hidden").parent().hide();自然会隐藏整个文档.因此,您必须更加具体.

$(":hidden") returns the <head>, <style>, <script> ,etc elements also. Their parent is the <html> document itself. So naturally $(":hidden").parent().hide(); will hide the entire document. Therefore you must be a bit more specific.

如@denisk所述,$('table:hidden').parent().hide();应该可以正常工作.

As told by @denisk $('table:hidden').parent().hide(); should work perfectly.

在您显示的代码中,它可能由于<h4>标记而无效.

In the code you have shown, it didn't work probably because of the <h4> tags.

这篇关于如果“子表"被隐藏,则隐藏“父Div"(显示:无)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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