tags:

views:

960

answers:

4

I have code that uses jquery.slideup and jquery.slidedown

How can i know that div is hidden?

+1  A: 

You can use the visible selector:

http://docs.jquery.com/Selectors/visible

JJ
+10  A: 

To see if an element is visible or not, you can use the visible selector with the is function:

$("#idElement").is(":visible") // true or false

But sounds to me like you want to toggle the slide effect, for that you can use the slideToggle function.

CMS
I could be wrong, but thats .is(":visible") (with the colon)?
Hugoware
thanks for answer, nice to know there is something like .is function
mamu
@HBoss: yes, you are right
CMS
+4  A: 
$('#id').is(':hidden');    //true if is hidden
$('#id').is(':visible');   //true if is visible

But you may want to use slideToggle for your needs.

Daniel Moura
watch the quotes there - you have $("#id') where you mean $('#id').
DDaviesBrackett
@DDaviesBrackett: thanks. corrected.
Daniel Moura
A: 

You could use $("#elementID").height() == 0 since you know it is either going to be up or down. It may be faster than doing the .is(":visible") as well but I haven't done any testing on that fact.