自动隐藏可见子元素
我正在使用 HTML、JavaScript 和 CSS 进行一些原型设计。该原型是在移动设备上运行的应用程序套件。每个屏幕都内置在其自己的 DIV 中。有一个主屏幕,几个屏幕,等等。
用户应该能够随时转储到主屏幕。每个屏幕中都有某些默认可见的元素,以及基于某些操作专门设置为可见的其他元素。
我遇到的问题是,当将屏幕 DIV 之一设置为隐藏时,我仍然可以看到我专门设置为可见的该 DIV 的子元素。我知道有一个预先存在的代码隐藏了目标 DIV 的所有子元素,但我只想隐藏我已经设置为可见的子元素。
有没有代码可以帮助我解决这个问题?我可以构思一种围绕此进行编程的方法,但我不想重新发明轮子。
示例 HTML:
<div id="parentDiv">
<span id="childElement" style="visibility:hidden"></span>
</div>
示例 JavaScript:
$('childElement').style.visibility = 'visible';
$('parentDiv').style.visibility = 'hidden';
完成此示例后,我仍然可以看到 childElement。
注意:在 Windows XP 上使用 Opera
I am doing some prototyping using HTML, JavaScript and CSS. The prototype is for an application suite to run on a mobile device. Each screen is built in it's own DIV. There is one home screen, several screens off that, et cetera.
The user should be able to dump out to the home screen at any time. There are certain elements in each screen that are visible by default, and other elements that are specifically made visible, based off certain actions.
The issue I am having is that when setting one of the screen DIVs to hidden, I can still see the child elements of that DIV that I have specifically made visible. I understand there is pre-existing code which hides all child elements of a target DIV, but I only want to hide the one's I've made visible.
Is there code out there which will help me with this? I can conceptualize a way I could program around this, but I don't want to reinvent the wheel.
Sample HTML:
<div id="parentDiv">
<span id="childElement" style="visibility:hidden"></span>
</div>
Sample JavaScript:
$('childElement').style.visibility = 'visible';
$('parentDiv').style.visibility = 'hidden';
After doing this sample, I can still see childElement.
Note: using Opera on Windows XP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
then 使其可见
try using
then to make it visible