Greetz,
I am new to JS and using code that someone gave me.
I have cleaned up the code, made it standard compliant and tailored it to my need.
The code is for an ultra basic picture gallery. The code is almost perfect, but there is one undesirable effect in which when an image is selected from the thumbnail gallery, the thumbnail dissapears as I am guessing its the same element, just blown up.
What I would like to know is how I can stop it from happening?
I will post the full output of the HTML file. I have also uploaded zip file which contains the HTML file and two images, so one may see the compiled page as I do.
Zip file (Note: STUPID hosting site placed the DOWNLOAD button right under "MP3 ringtones"... Clicking download will not take you to some premium SMS service or anything like that):
http://qfs.mobi/f31666
Code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<TITLE></TITLE>
<META content="charset=windows-1252;text/html" http-equiv="content-type">
<SCRIPT type="text/javascript">
clickMenu = function(menu) {
var getEls = document.getElementById(menu).getElementsByTagName("LI");
var getAgn = getEls;
for (var i=0; i<getEls.length; i++) {
getEls[i].onclick=function() {
for (var x=0; x<getAgn.length; x++) {
getAgn[x].className=getAgn[x].className.replace("click", "");
}
this.className+=" click";
}
}
}
</SCRIPT>
<STYLE type="text/css">
#gallery ul {
float:right;
overflow:auto
}
#gallery ul li {
display:inline;
width:50px;
height:50px;
float:left;
margin:0 4px 4px 0;
border:1px solid #444;
cursor:pointer
}
#gallery ul li img {
display:block;
height:50px
}
#gallery ul li span {
display:none;
position:absolute;
left:447px;
top:235px;
font-family:verdana;
color:#06a
}
#gallery ul li.click {
border-color:#fc0;
cursor:default
}
#gallery ul li.click i {
position:absolute;
left:0;
width:545px
}
#gallery ul li.click i img {
margin:5px auto 0 auto;
height:auto
}
#gallery ul li.click span {
display:block
}
</STYLE>
<BODY onload="clickMenu('gallery')">
<DIV id="gallery">
<UL>
<LI><I><IMG src="1.png" title="" alt=""></I><SPAN>Front</SPAN></LI>
<LI><I><IMG src="2.png" title="" alt=""></I><SPAN>Back</SPAN></LI>
</UL>
</DIV>
</BODY>
Much appreciated!