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;