简体   繁体   中英

javascript to hide div if homepage

I want to hide a #div if it's on homepage. Anyone can help with the javascript or php?

I found something like this but its certainly not working. Bear with me as im really clueless on codes.

<?php if (!is_page('home') ) { echo <div id="toolbar">;} ?>

jQuery的:

$("body.home #div").hide();

if you're using a PHP framework you can use it's helper functions, but in pure PHP you can use $_SERVER['PHP_SELF'] superglobal to get the currently executing file path.

So you can do something like this:

<?php if($_SERVER['PHP_SELF'] != '/home.php') { ?>
    <div id="toolbar">
        ...
    </div>
<?php } ?>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM