Answer in Web Application for RajaShekhar #158271

I need some help creating a modularized JavaScript roll-over function for gallery images that functions correctly and permits additions of images without the need to hard-code the values. I believe the preload is working as it should, but I haven’t quite connected all of the dots for the rollover as described below.

Hint: Preloading your images will only work on a hosting server and not your local drive as there’s no load time for your images locally. Once you have preloaded those images, you may want to clear your cache to test your loading of the images again.

Tip: In a smaller JavaScript program such as this one, each function is created for a specific purpose. However, in more complex sites, it is better to build functions that we can apply to multiple situations. For example, rather than specifying an element name or id, we can use a variable that is passed into the function.


Use the gallery.html and index.html files that you downloaded in the Zip file in Assessment 1. Create functionality using JavaScript on the following pages:


Preload the gallery images.

Create rollover functionality for each of the thumbnails in your image gallery. Use appropriate images found in the images folder.

Write developer comments to describe the variables being declared and explain the functions and logical blocks of JavaScript code pertaining to the gallery.

Make sure to do the following:

Create an onpageload function to preload all of your images.

Create a modularized rollover function for gallery images.

Here is the HTML code I have so far:

<!DOCTYPE html>

<html lang=”en-US”>


<title>Invitation Page</title>

<link rel=”stylesheet” type=”text/css” href=”css/main.css” />

<script src=”js/galleryImages.js”>

//added preload for the js file preload function

preload(‘images/firefighter.jpg’, ‘images/work.jpg’, ‘images/silhouette.jpg’, ‘images/event.jpg’);





<div class=”top”>

<a class=”logo” href=”index.html”>CapellaVolunteers<span class=”dotcom”>.org</span></a>



<ul class=”topnav”>

<li><a href=”index.html”>Home</a>


<li><a href=”invitation.html”>Invitation</a>


<li><a href=”gallery.html” class=”active”>Gallery</a>


<li><a href=”registration.html”>Registration</a>





<section id=”gallery”>

<div class=”gallery”>

<a target=”_blank” href=”images/firefighter.jpg”>

<img class=”image” src=”images/firefighter.jpg” alt=”firefighter” width=”300″ height=”200″> <!– added new class image to identify the roll over event with url of the selected image –>


<div class=”desc”>Add a description of the image here</div>


<div class=”gallery”>

<a target=”_blank” href=”images/work.jpg”>

<img class=”image” src=”images/work.jpg” alt=”work” width=”300″ height=”200″> <!– added new class image to identify the roll over event with url of the selected image –>


<div class=”desc”>Add a description of the image here</div>


<div class=”gallery”>

<a target=”_blank” href=”images/silhouette.jpg”>

<img class=”image” src=”images/silhouette.jpg” alt=”silhouette” width=”300″ height=”200″> <!– added new class image to identify the roll over event with url of the selected image –>


<div class=”desc”>Add a description of the image here</div>


<div class=”gallery”>

<a target=”_blank” href=”images/event.jpg”>

<img class=”image” src=”images/event.jpg” alt=”event” width=”300″ height=”200″> <!– added new class image to identify the roll over event with url of the selected image –>


<div class=”desc”>Add a description of the image here</div>


<div id=”fullImage”></div> <!– added new DIV to display full image dynamically from JS–>


<footer>This events site is for IT-FP3215 tasks.




Here is the JS I have:

//Preload function has to be included

var images = [];

//function to preload banner images

function preloadBannerImages() {

// get the src of all banner images in document and then preload them

for (var i = 0; i < images.length; i++) {

var img = new Image();

img.src = images[i].src;


console.log(‘Preloading completed!’);


/*Example of code from professor for this functionality

function setupRollover(‘img1’) {

theImage.outImage = new Image();

theImage.outImage.src = theImage.src;

theImage.oumouseout = function () {

this.src = this.outImage.src;



//Rollover functionality using modularized code

var imageGallery = function () {

var sliderInd = 0; //defining global index to count slide images.


addListeners = function () {

var items = document.getElementsByClassName(“image”); //getting img elements by CSS class name to register event

for (let index = 0; index < items.length; index++) {

const element = items[index];

element.addEventListener(“mouseover”, this.loadFullImage, false);



loadFullImage = function (event) // mouse over event handler function to load full image



document.getElementById(“fullImage”).innerHTML = ‘<img src=”‘ + + ‘”/>’; //adding full image to DIV


retObject = {

//public function in return object will be exposed to other members.

init: function () {

addListeners(); // calling method to register mouse over events



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        body {
            margin: 20px;
            padding: 0;
            background: #333333;
        .container {
            max-width: 400px;
            margin: auto;
            border: #fff solid 3px;
            background: #fff;
        .main-img img, .imgs img {
            width: 100%;
        .imgs {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-gap: 5px;
        @keyframes fadeIn {
            to {
                opacity: 1;
        .fade-in {
            opacity: 0;
            animation: fadeIn 0.5s ease-in 1 forwards;
    <div class="container">
        <div class="main-img">
            <img src="images/image1.jpg" alt="picture" id="current">
        <div class="imgs">
            <img src="images/image1.jpg" alt="picture">
            <img src="images/image2.jpg" alt="picture">
            <img src="images/image3.jpg" alt="picture">
            <img src="images/image4.jpg" alt="picture">
            <img src="images/image5.jpg" alt="picture">
            <img src="images/image6.jpg" alt="picture">
            <img src="images/image7.jpg" alt="picture">
            <img src="images/image1.jpg" alt="picture">
        const current = document.querySelector('#current');
        const imgs = document.querySelectorAll('.imgs img')
        const opacity = 0.4;
        imgs[0].style.opacity = opacity;
        imgs.forEach(img => img.addEventListener('click', imgClick));
        function imgClick(e) {
        imgs.forEach(img => { = 1});
        current.src =;
        setTimeout(() => current.classList.remove('fade-in'), 500); = opacity;

// the pictures must be in the images folder named in the code

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with TheBestPaperWriters
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Architecture, Building and Planning
The assignment was well written and the paper was delivered on time. I really enjoyed your services.
Customer 452441, September 23rd, 2022
The paper was EXCELLENT. Thank you
Customer 452449, September 23rd, 2022
excellent loved the services
Customer 452443, September 23rd, 2022
Business Studies
Thank you!
Customer 452451, November 27th, 2022
Thanks a lot the paper was excellent
Customer 452453, October 26th, 2022
Public Administration
Excellent timely work
Customer 452451, April 19th, 2023
Business Studies
Excellent service - thank you!
Customer 452469, February 20th, 2023
Job well done and completed in a timely fashioned!
Customer 452451, November 18th, 2022
English 101
Very good job. I actually got an A
Customer 452443, September 25th, 2022
Business Studies
Job well done. Finish paper faster than expected. Thank you!
Customer 452451, October 3rd, 2022
Excellent services will definitely come back
Customer 452441, September 23rd, 2022
Customer reviews in total
Current satisfaction rate
3 pages
Average paper length
Customers referred by a friend
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat