Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'm doing some review JS work and have a task list that has me stumped. Create a class Image with two properties, imgName and description.
I'm doing some review JS work and have a task list that has me stumped.
- Create a class Image with two properties, imgName and description.
- Create an image object off the Image class for all images stored in the images folder, and add all of them an array called galleryPhotos.
- Use a loop to add all images in the galleryPhotos array to the gallery page using DOM node operations. NOTE: innerHTML is not allowed for this task. HINT: Each iteration of the loop will create one img node and add it to the containing element, e.g., main. The loop body would more or less look like below:
- Make an img node.
- Add the src and alt attributes to the img node, e.g., src: `images/${galleryPhotos[i].name}.jpg`; alt: galleryPhotos[i].description. Here it assumes that a) the image object only has the file name but not the folder name or the file extension; b) the images are stored in the images folder of the website and all have an jpg file extension.
- Add the img node to the containing element. The variable referencing the containing element should be created before the loop
- Add the Gallery link to the site navigation bar using JavaScript.
NOTE: innerHTML is not allowed for this task.
The procedure would be similar to creating the gallery page images:- Create an 'a' node, then create and add to it the href attribute and textNode for the clickable text;
- create an 'li' node and add the 'a' node to it;
- find the first ul element in the nav container or in the document (you may assume the ul in nav is the first ul on the page) then add the 'li' node to the 'ul' container.
I have both an HTML and JS file ready to go and the images in a folder called "imgGallery". I'm just completely stumped on this question/task list.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started