Overview
This lab helps you to solidify the basics of manipulating the DOM with JavaScript and event-based programming with JavaScript. You will create an interactive photo gallery.
Requirements
- Download the starter file from this Dropbox link.
- Do not change the HTML or CSS code. You only need to write JavaScript.
- Do not use inline JavaScript. This is bad practice. Write event handlers like we did in class.
- In the browser, open up the console like in the lecture and have it open as you complete this lab. It will be helpful to see errors right away. You can also log things out on the browser to test your code.
- When a user clicks on a thumbnail:
- Make the clicked thumbnail fully opaque (meaning NOT transparent).
- Make all other thumbnails 60% opaque (40% transparent).
- Make the border color of the clicked thumbnail red (#F00000).
- Make the border color of all other thumbnails black (#000000).
- Update main image to clicked thumbnail image.
- Hint: try logging out the thumbnail’s
children
property in theconsole
.
- Hint: try logging out the thumbnail’s
- Update main image’s alt attribute to clicked thumbnail’s alt attribute.
- Update the caption below the main image to the clicked thumbnail’s alt attribute.
- Hint: “Reset” all thumbnails every time a user clicks on a thumbnail. Only change the border and opacity on the thumbnail that was clicked.
Sample
Submission/Upload to the server
Please follow the submission requirements below carefully. You will be deducted points for not following submission requirements to the teeth.
- Open FileZilla and connect to the itpwebdev server as you have done in Lab 1 (click File -> Site Manager). If you forgot how to connect, follow this guide on how to connect and upload files to the itpwebdev web server.
- After you have successfully connected to the itpwebdev server, upload the entire starter file folder (named
lab04
) into the thepublic_html
folder. Make sure the images are uploaded as well.- In your browser, go to
http://303.itpwebdev.com/~yourusername/lab04/lab04.html
to check that the assignment file has been uploaded correctly.
- In your browser, go to
- One last thing. In your computer, open up
student_page.html
that you created in Lab 1. Add a link to this assignment tostudent_page.html
under the heading “Labs” so that the TAs can easily access your completed assignment. - Upload the updated
student_page.html
to the itpwebdev server via FileZilla inside thepublic_html
folder. If it asks you want to overwrite the previous file, click Yes. - (Optional) If you are having trouble uploading to the server and cannot upload on time, add all files for this assignment in a folder, compress it as a .zip file and upload it to Blackboard. On Blackboard, go to Assignments -> Lab 4: JS Photo Gallery. You will get some points deducted for not uploading correctly but at least you will not get a zero.