Jump to content

hideShow and id with one button


freelance84

Recommended Posts

Is this correct?

 

I'm trying to write a simple function that will hide an id or show depending on its current status

 

function hideShow(id)
{
	document.getElementById(id)
	if (id == 'none')
		{
			document.id.style.display = 'inline';
		}
	else
		{
			document.id.style.display = 'none';
		}

}

Link to comment
https://forums.phpfreaks.com/topic/216491-hideshow-and-id-with-one-button/
Share on other sites

function hideShow(id)
{
	if (document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'inline';
		}
	else
		{
			document.getElementById(id).style.display = 'none';
		}

}

 

Wierd isn't it, you can't do something for ages, post it on a forum and the pressure mounts to not look stupid so your mind sees the solution!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.