-1

Possible Duplicate:
Get CSS style from PHP

I want to make an if that will do things, only if div's display is not none. Here is an example:

<div id="div_1" style="display:none;">blah blah blah</div>
<?php if (div_1 display is none){...} else {echo $variable;} ?>

Any idea how will I syntax this part (div_1 display is none)??? If it can be of-course! Thank you in advance!

Community
  • 1
  • 1
DNA180
  • 266
  • 1
  • 7
  • 28

3 Answers3

2

You cant do that server-side. Maybe you can use JavaScript and Jquery is a good tool:

if($('#div_1').css('display') == 'none')
{
    ...
}
else {
    $('#Some_Div').html('...');
}
Hosein
  • 581
  • 1
  • 7
  • 29
1

for non-jquery plain 'ol javascript

if (element.style.display == 'none'){
   //your element is not visible
} else {
   //your element is visible
}
hobberwickey
  • 6,118
  • 4
  • 28
  • 29
0

You can use Ajax and JavaScript

<script>
$(document).ready(function() {
if($('#div').is(':hidden')) {
$.ajax({
   url: "file.php",
   type: "POST",
   data: {somedata: "data"}, 
      success: function(msg) {

       $("#div").html(msg);
      }
});
}
else {
//...
}
});
</script>