Reputation: 13
I've figured out how to show an element on mobile
<?php if(detectMobile()) { ?>
htmlcode
<?php } ?>
However i'm trying the opposite and want to HIDE an element on mobile.
I know this is possible with css but in this case i don't want to use the display:none
option because its using the same css like some other elements that should not be hidden on mobile. Also creating a unique css is not what i want in this case.
Upvotes: 0
Views: 196
Reputation: 884
Simply change your if yes to an if no by adding a ! (not operator)
Your code becomes:
<?php
if( !detectMobile() )
{
?>
htmlcode
<?
}
?>
or alternatively, use an if else construction. Your code becomes:
<?php
if( detectMobile() )
{
// future code in case we must do something for mobile.
?>
<?
}
else
{
// if not mobile, then this code is being used.
?>
htmlcode
<?
}
?>
Upvotes: 1