Pure Rhymer Organization Pure Rhymer Organization - 6 months ago 25
jQuery Question

PHP session and hide table with jQuery

Is it possible to hide the table with jQuery if their is session present?

this is my session code

<?php
$username = $this->session->userdata('username');
if($username == TRUE){
echo "WELCOME ".$username;
}else{
echo "<div class='msg'>Please Log In</div>";
}
?>


and in my jQuery I dont know what to put in IF statement so I put it like this

if(".msg:visible"){
$('table').hide();
}


If possible I want to hide the table using jQuery

Answer

You can do using jQuery try below code

if ($(".msg").length > 0) {
    $('table').hide();
}