Possible Duplicate:
what is the solution to remove/add a class in pure javascript?
Firstly forgive what seems to be a simple javascript question, I have just started getting to grasps with the language. I have seen numerous posts on showing and hiding content by either classes or ids, but they all seem to apply to one at a time. I would like to change three classes at a time and what display change is depends on what links the user has all ready clicked on. Confusing explanation I know but my example with code is below.
I am building an image gallery with a series of thumbnails that all have classes assigned to them; .photo
, .print
and .logo
. The desire is to have four 'buttons'; photo, print, logo and display all. When the user clicks "photo" the code will set .photo to display:block
, and .print
and .logo to display:none
. When the user clicks "print" the code will set .print to display:block
, and .photo and .logo to display:none
. When the user clicks "logo" the code will set .logo to display:block
, and .photo and .print to display:none
. And obviously when the user clicks "display all" all classes are set to display:block
.
<div id="menu">
<ul class"toplevel">
<li id="photoselect"><a href="photo.html">Photography</a></li>
<li id="logoselect"><a href="logo.html">Print</a></li>
<li id="printselect"><a href="print.html">Logo</a></li>
</ul>
</div>
<div id="content">
<a href="photo/photo01.jpg" class="" rel="lightbox" title="Caption from the anchor's title attribute"><img class="thumb photo" src="photo/photo01.jpg"></a>
<a href="photo/photo02.jpg" class="" rel="lightbox" title="Caption from the anchor's title attribute"><img class="thumb photo" src="photo/photo02.jpg"></a>
<a href="photo/photo03.jpg" class="" rel="lightbox" title="Caption from the anchor's title attribute"><img class="thumb print" src="photo/photo03.jpg"></a>
<a href="photo/photo04.jpg" class="" rel="lightbox" title="Caption from the anchor's title attribute"><img class="thumb print" src="photo/photo04.jpg"></a>
<a href="photo/photo05.jpg" class="" rel="lightbox" title="Caption from the anchor's title attribute"><img class="thumb logo" src="photo/photo05.jpg"></a>
<a href="photo/photo06.jpg" class="" rel="lightbox" title="Caption from the anchor's title attribute"><img class="thumb logo" src="photo/photo06.jpg"></a>
</div>