Since the question refers to a single element, this code might be more suitable:
(由于问题涉及单个元素,因此此代码可能更合适:)
// Checks css for display:[none|block], ignores visibility:[true|false]
$(element).is(":visible");
// The same works with hidden
$(element).is(":hidden");
Same as twernt's suggestion , but applied to a single element;
(与twernt的建议相同,但适用于单个元素。)
and it matches the algorithm recommended in the jQuery FAQ (它与jQuery FAQ中推荐的算法匹配)
We use jQuery is() to check the selected element with another element, selector or any jQuery object.
(我们使用jQuery is()与另一个元素,选择器或任何jQuery对象一起检查选定的元素。)
This method traverses along the DOM elements to find a match, which satisfies the passed parameter. (此方法遍历DOM元素以找到匹配项,该匹配项满足传递的参数。)
It will return true if there is a match otherwise returns false. (如果存在匹配项,则返回true,否则返回false。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…