I am looking for a way to dynamically hide a DIV based on user roles using only the text inside a title tag as a reference.
Here is an example of the HTML structure:
<title>admin</title>
If the user role is admin, then hide the following DIV:
<div class="demo"></div>.
I must accomplish this task using Vanilla JavaScript only.
One issue I have encountered is that while my current solution successfully hides the div, it briefly shows up during page load:
$('document').ready(
function() {
function _title(){
if(document.title=="admin"){
document.getElementById('demo').style.display="none";
}
}
window.onload=_title;
});