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{
}
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{
}
You need to use the css
function.
if($("#toshow").css("display") == "block"){
}else{
}
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
.
Don't forget your :visible
selector.
if ($("#toshow:visible").length) {
// it's visible
} else {
// it's not visible
}
$(document).ready(function(){
if ($('#toshow').css('display') == 'block') {
// Do something.
} else {
// Do something else.
}
});
Should do the trick.