Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery, how to know div is hidden?

Tags:

jquery

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

How can i know that div is hidden?

like image 204
mamu Avatar asked Jun 30 '09 18:06

mamu


People also ask

How do you find if a div is hidden in jQuery?

Answer: Use the jQuery :visible Selector You can use the jQuery :visible selector to check whether an element is visible in the layout or not. This selector will also select the elements with visibility: hidden; or opacity: 0; , because they preserve space in the layout even they are not visible to the eye.

Is div visible jQuery?

You can use .is(':visible') selects all elements that are visible.


2 Answers

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.

like image 50
Christian C. Salvadó Avatar answered Sep 23 '22 01:09

Christian C. Salvadó


$('#id').is(':hidden');    //true if is hidden $('#id').is(':visible');   //true if is visible 

But you may want to use slideToggle for your needs.

like image 25
Daniel Moura Avatar answered Sep 22 '22 01:09

Daniel Moura