开发者

Test condition for visibility check in JavaScript

I'd like to know if there's a test conditions using which one can check 开发者_C百科the visibility state(hidden or visible) of a tag.

I mean a test condition,which could be used with the if() statement.

thanks!


if you are using jQuery then:

$('#id').is(':visible');


In case you don't use jQuery this simple javascript condition should work:

if(document.getElementById("elementId").style.visibility=="visible"){
    // do something
}


Simple solution is to use jQuery and do $('#id').is(':visible'). Otherwise you'll be writing a function that doesn't work as well and isn't as nicely coded.


If you use jQuery, it's very easy:

if ($(SELECTOR).is(":visible")) {
  // do amazing things
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜