Jump to content



Recommended Posts

So they're invisible when the page loads. That implies CSS. Depending on your needs, use one of these:

a.hidden { display: none }/* OR */a.hidden { visibility: hidden }

HTML looks like this:

<a class="hidden" id="special1"><a class="hidden" id="special2">

Then your javascript looks like this:

function show_links () {   document.getElementById("special1").style.visibility = "visible";   document.getElementById("special2").style.visibility = "visible"; }window.onload = show_links; // NO PARENTHESES

Link to comment
Share on other sites

I'm sorry, I'm still confused. I want to use the visibility:hidden in the CSS so my HTML is something like <a class="hidden" id="special2"> and then my javascript snippet goes like this: (??)

function show_links () {   document.getElementById("special2").style.visibility = "visible"; }window.onload = show_links; // NO PARENTHESES

Could I do it with a class instead of IDs?Thanks for your help ... I find javascript utterly muddling so apologies if I come off as a bit of an idiot.

Link to comment
Share on other sites

Could I do it with a class instead of IDs?
Yeah. One way would be to get all the links that are on your page, loop through the links looking for any that have a class of "hidden", and then removing the class name to un-hide them.
<a class="hidden">some link</a>

function show_links(){	var links = document.getElementsByTagName("a");	for(var i = 0; i < links.length; i++)	{		if(links[i].className == "hidden")		{			links[i].className = "";		}	}}window.onload = show_links;

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...