Jump to content

Making a div appear and disappear SOLVED with thanks in the last post


niche

Recommended Posts

This makes my div appear (when the display attribute is set to none) using the onclick event:

divTest = document.getElementById('linkContainer2');if (divTest.style.display === "none") {	divTest.style.display = '';}

I thought this would make it appear and disappear (depending on the display attribute) using the onclick event, but it doesn't. Why?

divTest = document.getElementById('linkContainer2');if (divTest.style.display === "none") {		divTest.style.display = '';	 } elseif (divTest.style.display === "") {		 divTest.style.display = "none";	}

Edited by niche
Link to comment
Share on other sites

That was it. For everything there is a first time. I didn't have that distinction in my head until now. Thanks again dsonesuk and for your effort So Called. Also, I appreciate your comment justsomeguy. That probably wouldn't have occurred to me.

Link to comment
Share on other sites

Guest So Called

YWVM... I write too much PHP and didn't realize that PHP's elseif doesn't go for JS. So I learned something too.

Link to comment
Share on other sites

Both of us get to do better now that we know better!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...