HTML/JavaScript: Toggle multiple divs?

Matthew M

New member
Hi, I'm a student learning HTML and CSS, which I have down pretty easily. However, I know almost nothing about JavaScript, but I'm pretty sure I'm going to have to use it for what I'm trying to do...

I have a grid of 9 images at the top of the page. I have also made 9 currently hidden divs (named div1, div2, div3, etc.) at the bottom of the page; each div corresponds to an image. I'm trying to make it so when you click on an image, the corresponding div appears and all the other divs hide.

Can someone please post the exact HTML and JavaScript code that would allow me to do this? I've checked other sites and found things identical to what I was looking for, but I had trouble editing the JavaScript (which, like I said, I know nothing about), so a precise step-by-step answer (if it applies) would be greatly appreciated.

Thank you!
 
Back
Top