4,114
edits
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 124: | Line 124: | ||
function setupImageToggle(images) { | function setupImageToggle(images) { | ||
var currentIndex = 0; | var currentIndex = 0; | ||
function toggleImage() { | function toggleImage() { | ||
currentIndex = (currentIndex + 1) % images.length; | currentIndex = (currentIndex + 1) % images.length; | ||
var image = images[currentIndex]; | var image = images[currentIndex]; | ||
$('#article-content').find('.article-image | |||
// Update image source and alt text | |||
var articleImageContainer = $('#article-content').find('.article-image'); | |||
articleImageContainer.find('img').attr('src', image.src).attr('alt', image.alt); | |||
// Update the caption | |||
articleImageContainer.find('.caption').text(image.caption); | |||
} | } | ||
// Attach click event to image for toggling | // Attach click event to image for toggling | ||
$('#article-content').on('click', '.article-image img', function () { | $('#article-content').on('click', '.article-image img', function () { |