tags:

views:

332

answers:

4

i am trying trying to find out if a div style display is block then do something here is an e.g

this is just a guess i am tryng to do it in jquery

 if("#toshow":"display" == "block"){

 }else{

 }
+3  A: 

You need to use the css function.

if($("#toshow").css("display") == "block"){

}else{

}
Brian McKenna
+3  A: 

So you want to distinguish between display: block and display: none ? If so, you can better use the is() function in combination with the :visible selector for this:

if ($('#toshow').is(':visible')) {

} else {

}

This works regardless of if you used display: block, or display: inline, or display: inline-block.

BalusC
+2  A: 

Don't forget your :visible selector.

if ($("#toshow:visible").length) {
  // it's visible
} else {
  // it's not visible
}
Jonathan Sampson
A: 
$(document).ready(function(){
    if ($('#toshow').css('display') == 'block') {
        // Do something.
    } else {
        // Do something else.
    }
});

Should do the trick.

anomareh