0

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!

Edited by public-image: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Airshow
0

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

Edited by Airshow: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.