27 lines
698 B
JavaScript
Raw Normal View History

2021-03-31 21:56:49 -04:00
"use strict";
$(document).ready( () => {
// preload images
$("#image_list a").each( (index, link) => {
const image = new Image();
image.src = link.href;
});
// set up event handlers for links
$("#image_list a").click( evt => {
// get clicked <a> tag
const link = evt.currentTarget;
// swap image
$("#main_image").attr("src", link.href);
//swap caption
$("#caption").text(link.title);
// cancel the default action of the link
evt.preventDefault();
});
// move focus to first thumbnail
$("li:first-child a").focus();
});