• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 6 pages
Exam (elaborations)

JavaScript Chapter 7 with correct answers 100% 2025

Document preview thumbnail
Preview 2 out of 6 pages

JavaScript Chapter 7 with correct answers 100% 2025 Why might you want to preload images on a page that uses rollovers? A. To prevent delays displaying the images when the swapped images are large. B. To prevent delays displaying the images when the connection is slow. C. To prevent delays when the page is being loaded. D. All of the above. E. A and B only. - A and B only. Assuming that the href attribute of each a element contains the URL for an image, what does the code that follows do? const flowers = SelectorAll("a"); for (let flower of flowers) { const image = new Image(); = ;} A. It stores all a elements in an array named flowers. B. It creates a new Image object for each image in the flowers array. C. It preloads each Image object. D. All of the above. E. A and B only. - All of the above. Given this HTML: main h1Image Swap/h1 pClick on an image to enlarge./p ul id="image_list" lia href="images/" title="dogs" img src="thumbnails/" alt=""/a/li lia href="images/" title="cats" img src="thumbnails/" alt=""/a/li /ul h2 id="caption"Animals/h2 pimg id="main_image" src="images/" alt=""/p /main Why are the img elements for the thumbnails coded within the a elements? A. So the user can swap the main image by pressing Enter when a thumbnail has the focus. B. So the user can access the thumbnail links by pressing the Tab key.

Content preview

JavaScript Chapter 7 with correct
answers 100% 2025
Why might you want to preload images on a page that uses rollovers?

A. To prevent delays displaying the images when the swapped images are large.
B. To prevent delays displaying the images when the connection is slow.
C. To prevent delays when the page is being loaded.
D. All of the above.
E. A and B only. - A and B only.

Assuming that the href attribute of each <a> element contains the URL for an image,
what does the code that follows do?

const flowers = document.querySelectorAll("a");
for (let flower of flowers) {
const image = new Image();
image.src = flower.href;}

A. It stores all <a> elements in an array named flowers.
B. It creates a new Image object for each image in the flowers array.
C. It preloads each Image object.
D. All of the above.
E. A and B only. - All of the above.

Given this HTML:

<main>
<h1>Image Swap</h1>
<p>Click on an image to enlarge.</p>
<ul id="image_list">
<li><a href="images/pic1.jpg" title="dogs">
<img src="thumbnails/t1.jpg" alt=""></a></li>
<li><a href="images/pic2.jpg" title="cats">
<img src="thumbnails/t2.jpg" alt=""></a></li>
</ul>
<h2 id="caption">Animals</h2>
<p><img id="main_image" src="images/pic1.jpg" alt=""></p>
</main>

Why are the img elements for the thumbnails coded within the <a> elements?

A. So the user can swap the main image by pressing Enter when a thumbnail has the
focus.
B. So the user can access the thumbnail links by pressing the Tab key.

, C. So the application is easy to use by the motor-impaired.
D. All of the above. - All of the above.

Which example line or lines of code attach an event handler for the click event of each
link?

A. document.addEventListener("DOMContentLoaded", () => {
const caption = $("#caption");
const mainImage = $("#main_image");
const imageLinks = $("#image_list").querySelectorAll("a");

B. for (let link of imageLinks) {
const image = new Image();
image.src = link.href;

C. link.addEventListener("click", evt => {
mainImage.src = link.href;
mainImage.alt = link.title;
caption.textContent = link.title;
evt.preventDefault();
});

D. imageLinks[0].focus(); - link.addEventListener("click", evt => {
mainImage.src = link.href;
mainImage.alt = link.title;
caption.textContent = link.title;
evt.preventDefault();
});

const imageLinks = $("#image_list").querySelectorAll("a");

for (let link of imageLinks) {
const image = new Image();
image.src = link.href;

What does the link variable refer to?

A. the image that's currently being processed
B. the <a> element that's currently being processed
C. the <img> element that the user clicked on
D. the <a> element that the user clicked on - the <a> element that's currently being
processed

link.addEventListener("click", evt => {
mainImage.src = link.href;
mainImage.alt = link.title;

Document information

Uploaded on
November 1, 2025
Number of pages
6
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$9.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Wairimumburia
3.5
(2)
Sold
25
Followers
3
Items
2742
Last sold
5 days ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions