How to hide two Divs inside each other with Javascript?

Asked

Viewed 125 times

0

I am facing a problem when trying to hide two divs, ie one inside the other. I can only hide one div the other is visible.

Follow what I’m using:

Java Script:

<script type="text/javascript">
function superpopgv(guaraparivirtualsuperpopup) {

    if(document.getElementById(guaraparivirtualsuperpopup).style.display=="none") {
        document.getElementById(guaraparivirtualsuperpopup).style.display = "inline";
    }
    else {
        document.getElementById(guaraparivirtualsuperpopup).style.display = "none";
    }

}
</script>

CSS:

#guaraparivirtualsuperpopup {
    position:relative;
    width:1215px;
    height:500px;
    background-color:#000000;
    /* background-image:url(http://www.guaraparivirtual.com.br/Lay_Out/dr-bruno.jpg);
    background-repeat:no-repeat;
    background-position:50% 50%;
    */
    margin: 0 auto;
    z-index: 9;
    border: 1px solid #EA8419;
}
#guaraparivirtualsuperpopupbtn {
    width:100px;
    height:36px;
    background-image:url(http://www.guaraparivirtual.com.br/img-novo/fechar.png);
    background-repeat:no-repeat;
    float:right;
    position: relative;
    z-index: 9999;  
}

DIV s

<div class="guaraparivirtual-topo-100-barra-inferior">

<a href="#" onclick="javascript: superpopgv('guaraparivirtualsuperpopup');" >
<div id="guaraparivirtualsuperpopupbtn"></div>
</a>

<a href="<?php echo $linkbannerrt; ?>" target="_blank" title="Super Pop-Up" / >
<div id="guaraparivirtualsuperpopup" style="background-image:url(superpopup/<?php echo $rt; ?>);"></div>
</a>

</div>
  • Can’t quite understand the example but the tip I give you is that if you hide the parent <div> surely you will hide the daughter, can pass more information to help you ??

1 answer

0

Obs: getComputedStyle(el) will return the current styles of the element, which makes it better to get the display of the element.


The problem is why you’re declaring "#guaraparivirtualsuperpopupbtn" e + elements outside the div "#guaraparivirtualsuperpopup". Your code needs a new structure to fit all those items outside the div main. Actually this is not a problem, but nothing is happening with the elements outside the div main. Its div is being treated as a daughter.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.