of course I want to understand this so I hope I understand it now,
1. the code I made before, is getting into the 'variable thePhotos'.
Correct. In JavaScript, everything is an object. So by creating a variable to store the result of "document.getElementById('thePhotos')", we're storing an HTML DIV Element Object (I'll give you a link to a real nice tutorial that explains what that means towards the bottom of the post ~_^).
2. When it's a variable we can add some more atributes on it.
Sort of correct. Actually, I just used a variable so that we wouldn't have to call document.getElementById twice. This would have worked just as well (and given how fast modern computers are, it would have executed just as fast):
- function showphoto(set) {
-
document.getElementById('photos').firstChild.src = set;
-
document.getElementById('photos').firstChild.style.visibility = 'visible';
-
}
3. Between the <div></div> every 'src' will be the value, wich is added by 'onclick do'
This one's up to you. What I did was create a single image whose source will be altered whenever the User clicks on any of the thumbnail images. Depending on the nature of your project, you may want to create a set number of full-size images and switch between them, or you may want to dynamically create images. The link to that article is coming; don't worry :)
4. after the 'onclick do' visibility='hidden' is getting visiblity=visible so I can see the div.
Correct. Since when the page first loads, the full-size image has no src. Rather than display a blank image (which different browsers handle differently), we keep it hidden. So naturally, once we assign it a src, we want it to be visible.
end. so far I understand it.
question: but what means 'firstChild' what is the function of it?
(I wanna learn javascript that's why my questions of course)
That is an admirable goal, borger. Welcome to DOM! Here's that link I've been telling you so many wonderful things about
:
http://www.quirksmode.org/dom/intro.html
Post back if you have any questions.