if ( $(this).is(':visible') )
should work for this relatively simple show/hide.
Sometime need to check that div is block or none. We can do this very easily . This is simple code . here id = "test"
-> for testing purpose if you use class = "test"
then need to update code
For checking Block or visible then use this for your select test
is id
1. if ($('#test').is(':visible')) {}
2. if ($('#test').css('display') == 'block'){}
3. if ($('#test').not(':hidden')){}
if your selector is class
then
1. if ($('.test').is(':visible')) {}
or
1. if ($(your_element).is(':visible')) {}
same other
For checking none or hide then use this code if your selector
is id
1. if ($('#test').not(':visible')){}
2. if (!$('#test').is(':visible')){}
3. if ($('#test').css('display') == 'none'){}
4. if ($('#test').is(':hidden')){}
if your selector is class then use this
1. if ($('.test').not(':visible')){}
or
1. if ($(your_element).not(':visible')){}
hope it will help you
You can try this:
$(your_element).is(":visible")
Example;
if ($('#element_id').is(":visible") ) {
// do something
}
You can use $(element).is(":visible")
to check if the element is visible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With