如何检查元素是否隐藏在jQuery中? [英] How do I check if an element is hidden in jQuery?

查看:117
本文介绍了如何检查元素是否隐藏在jQuery中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用函数 .hide() .show() .toggle()

如何检测元素是否可见或隐藏? p>

How would you test if an element is visible or hidden?

推荐答案

由于问题是指单个元素,所以该代码可能更合适:

Since the question refers to a single element, this code might be more suitable:

// Checks for display:[none|block], ignores visible:[true|false]
$(element).is(":visible"); 

twernt的建议,但适用于单个元素;它与匹配jQuery常见问题解答中推荐的算法

Same as twernt's suggestion, but applied to a single element; and it matches the algorithm recommended in the jQuery FAQ

这篇关于如何检查元素是否隐藏在jQuery中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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