I want to hide a div tag after checking If condition. It means I checked session roles with If condition, and then make a javascript to hide a div tag. Can you guys have any code look similar like I want.
<?php if ($_SESSION['role'] == 'Moderator' || $_SESSION['role'] == 'Editor') {?> <script type="text/javascript"> ---code hidden div tag here </script> <?php }?>
something like this, because I don't want these roles "Moderator, Editor" see or do action on the div tag I want. Can you guys help me out. Thank you!
The JS code would be like this:
//Get the div
var mydiv = document.getElementById("myDIV");
//Set display to none
mydiv.style.display = "none";
You can also do this without JavaScript like this:
<?php
if ($_SESSION['role'] == 'Moderator' || $_SESSION['role'] == 'Editor') {
?>
<div id="myDiv"></div>
<?php }?>
Place the div between the php if-statement
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.