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

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 =


  else if (browserType == "ie")

     document.poppedLayer =


            document.poppedLayer =


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


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>

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>