Toggle Visibility


#1

Hi,

I am setting the visibility of a object using the following:

hypeDocument.getElementById(mydoc).style.visibility = "hidden";

Currently I then use a button to set the visibility:

hypeDocument.getElementById(mydoc).style.visibility = "visible";

When the button is now clicked I would like to toggle the visibility, is this possible?

I have tried the JQuery toggle but have been unable to get this working.

Regards


#2

You could do a regular If then statement, and run it when clicking something:

   if ( hypeDocument.getElementById('mysquare').style.visibility == 'hidden') {
		hypeDocument.getElementById('mysquare').style.visibility = "visible";
	} else {
		hypeDocument.getElementById('mysquare').style.visibility = "hidden";
	}

toggle-visibility.zip (31.5 KB)


#3

Many thanks Daniel that would work great!