MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
commented out all other JS as it doesn't work anyway (???) |
try reducing errors by checking for button presence |
||
Line 94: | Line 94: | ||
// (test) Replaces image |
// (test) Replaces image |
||
document.getElementById('replaceImageButton') |
if (document.getElementById('replaceImageButton')) { |
||
document.getElementById('replaceImageButton').addEventListener('click', function() { |
|||
// Get a reference to the container element by its ID |
// Get a reference to the container element by its ID |
||
var container = document.getElementById('containerID'); |
var container = document.getElementById('containerID'); |
||
// Find the image element within the container |
// Find the image element within the container |
||
var imageElement = container.querySelector('img'); |
var imageElement = container.querySelector('img'); |
||
// Replace the image source with a new one |
// Replace the image source with a new one |
||
imageElement.src = document.getElementById('newImageURL').innerText; |
imageElement.src = document.getElementById('newImageURL').innerText; |
||
}); |
}); |
||
} |