隐藏父级 IF 子级范围设置为显示:无
我已经浏览了大多数与隐藏父容器相关的类似 JQuery 帖子,但似乎没有一个选项对我有用。
简而言之,我有以下代码
<div id="pagination" class="pagination">
<span class="previous disabled">« Previous</span>
<span class="next disabled">Next »</span>
</div>
*不是我的编码顺便说一句:-p
目前我商店中的分页 div(上面)是空的 - 发生这种情况是因为分页尚未被触发以显示上述代码中的上一个和下一个跨度。您可以看到它们的类名称为 .disabled,它只是将这些范围设置为 display:none。
我想创建一个 Jquery 函数,当子 span.previous 和 span.next 设置为 .disabled 时,该函数隐藏父 div #pagination。
感谢您的提前帮助!
I have gone through most similar JQuery posts relating to hiding parent containers but none of the options seemed to work for me.
In a nutshell I have the following code
<div id="pagination" class="pagination">
<span class="previous disabled">« Previous</span>
<span class="next disabled">Next »</span>
</div>
*Not my coding btw :-p
Currently the pagination div (above) on my store is empty - this happens because the pagination has not been triggered to show the previous and next spans in the above code. You can see that they have a class name of .disabled which just sets those spans to display:none.
I would like to create a Jquery function that hides the parent div #pagination when the child span.previous and span.next are set to .disabled.
Thanks for your help in advanced!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以
在这里小提琴 http://jsfiddle.net/hwrx2/
You could do
fiddle here http://jsfiddle.net/hwrx2/
这是未经测试的:
或
This is untested:
or
如果我不编写“逻辑”代码,我的第一个方法是更改默认值:隐藏父级并仅在没有禁用任何子级时才显示它。使用 jQuery,这很容易:
My first approach if I wouldn't write "logic" code would be to change the default: hide the parent and show it only if any of the children are not disabled. With jQuery that's easy: