Dryn Dryn - 1 month ago 10
HTML Question

How to hide an html element with php if a button is pressed?

I would like to hide a simple div, if someone click a button. The 'details' var holds an id from db.

<div class="greetings" <?php if(isset($_GET['details'])) {echo " style='display: none'"; } ?>
<p> some text </p>
<div>


But id doesn't work. I appreciate any suggestions :)

Answer

An alternative way.

<?php
$style = "";
if(isset($_GET['details'])){
    $style = "style='display:none;'";
}?>


<div class="greetings" <?php echo $style;?>>
  <p> some text </p>                       ^ You forgot to close
<div>
Comments