如何检查div是否为可见状态? [英] How to check if a div is visible state or not?
本文介绍了如何检查div是否为可见状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的标签.
<li id="singlechatpanel-1" style="visibility: hidden;">
//content
</li>
试图像这样检查它:
$(".subpanel a").click(function()
{
var chatterNickname = $(this).text();
if(!$("#singlechatpanel-1").is(':visible'))
{
alert("Room 1 is filled.");
$("#singlechatpanel-1").css({'visibility':'visible'});
$("#singlechatpanel-1 #chatter_nickname").html("Chatting with: " + chatterNickname);
}
如果条件总是返回false.如何查看该div的可见性状态?
If condition always returns false. How can I check visibility state of this div?
推荐答案
is(':visible')
检查元素的display
属性,可以使用css
方法.
is(':visible')
checks the display
property of an element, you can use css
method.
if (!$("#singlechatpanel-1").css('visibility') === 'hidden') {
// ...
}
如果将元素的display
属性设置为none
,则if
语句将返回true
.
If you set the display
property of the element to none
then your if
statement returns true
.
这篇关于如何检查div是否为可见状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文