How to hide a div?

I’ve been trying to hide a div with no luck. Here’s what I’ve got:

<script>
if ( window.location !== window.parent.location ) {
document.getElementById(promo).style.display = "none"; 
} else {
}
</script>
<div id="promo">Stuff here</div>

It should work!?

Hi @Freejoy, you might need to wrap promo in quotes inside getElementById

I just tried it with single and double quotes, still didn’t work. It works with document write so the if statement works.

Oh yeah maybe try to put your script after the HTML and keep the quotes

3 Likes

I put all my javascript right before the ending body element →

<footer class="footer-style">
    <p class="footer-name">&copy;<?php echo date("Y"); ?> <span>John R. Pepp</span></p>
</footer>
<script src="assets/js/mobile-nav.js"></script>
<script src="assets/js/sticky.js"></script>
<script src="assets/js/slideshow.js"></script>
<script src="assets/js/GoogleAnalytics.js"></script>
<script src="assets/js/privacy.js"></script>
<?php 
    if ($basename === 'blog.php') {
        echo '<script src="assets/js/blog-user-selection.js"></script>';
    }
?>

</body>
</html>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.