Sandor Sandor - 10 months ago 55
CSS Question

jQuery run function if CSS property present

I am trying to run a function if is visible and not allow it to run if is visible. My code is the following but it does not work. The function runs fine.

function onAnyChange(){
if ($('#text_side_content_submit').css('display') != 'none'){ something...

What I would like is to use something like:

.css('display') == 'visible')

but "display" does not have such a property. Based on the manual the default value of "display" is "inline", but that breaks the code. What should I use?

Answer Source

JQuery has :visible and :hidden selector. Use these selectors.

if($('#text_side_content_submit:hidden').length == 0){
// do something