Alex Rivera | Logout

How to know the status of the div in jquery?

Asked 2011-04-15T06:25:30.687
13

i am developin one application using jquery. i want to know the status of the div wheather the div is show state or hide state something like this:

if($("#test").show()==true) 
{
//some operration
}
else
{
//some operration
}

alert($("#test").show()==true); always shows false.

please help me...

Edit
Report

1 Answer

1

is(':visible') is, of course, correct.

In pretty much all my jQuery applications, I introduce a simple plugin isVisible.

$.fn.isVisible = function() {
    return $.expr.filters.visible(this[0]);
};

This is about 50 times faster than the above function (jsPerf example) for exactly the same functionality.

if ($('#yourElement').isVisible()) {
answered 2011-04-15T06:40:25.003

Your Answer