Okay so I was having a problem earlier where I could not get my DIV to hide using my script I used some source from google and got the following, I found it to be effective and do the job, however I want it so that when I click my "okay" button that it can close more than just one div.

My script is

<script>
var browserType;

 

if (document.layers) {browserType = "nn4"}

if (document.all) {browserType = "ie"}

if (window.navigator.userAgent.toLowerCase().match("gecko")) {

   browserType= "gecko"

}

 

function hidethis() {

  if (browserType == "gecko" )

     document.poppedLayer =

         eval('document.getElementById("alertzy")');

  else if (browserType == "ie")


     document.poppedLayer =

        eval('document.getElementById("alertzy")');

  else
            document.poppedLayer =

        eval('document.layers["alertzy"]');

  document.poppedLayer.style.visibility = "hidden";

}
</script>

And a small example of what source I have is:

<div id="back" style="visibility: visible;">
<div id="alertzy" style="visibility: visible;">
<p>Some content</p>
<center><a href="#" onclick="hidethis()">hide</a></center>
</div>
</div>

I would like to hide the "back" div also, and I am not great with javascript could anyone help me out?

Thanks in advance!

If you hide "back" there's no point hiding "alertzy" as well. When "back" is hidden, all its contents will be hidden too.

You can formulate the hider function like this:

function hidethis(element) {
  element.style.visibility = "hidden";
}

and call it like this to hide "back":

<a href="#" onclick="hidethis(this.parentNode.parentNode)">hide</a>

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.