Display class using javascript

hi JavaScript people,

I have fives div with a class tag when a page loads that is display:none; At some point I want
the divs to display and to keep it semantically correct I have used classes. But I can’t seem
to get them to display when a link is clicked. Below is where I have got to any help would be great.

	function displayDivs(){

		var displayMyclass = document.getElementsByTagName("myclass");
		displayMyclass.style.display = "block";

“myclass” isn’t a tag name, but a class name. getElementByClassName isn’t supported in all browsers, though, so you may need something more elaborate.

Try to display elements using jquery.
Something like var elements = $(“.myclass”);
And then use “elements” variable like an array of your elements, which have a necessary class.

JQuery is overkill if all you are after is a class name lookup.

See http://javascriptexample.net/dom04.php for a working example of how to add getElementsByClassName to those browsers that don’t support it while using the built in call in those browsers that do.