MediaWiki:Common.js: Difference between revisions

From Celeste Wiki
Content deleted Content added
shortened even more, maybe this fixes the issue
seems like jQuery does not work, reversing
Line 94: Line 94:
// (test) Replaces image
// (test) Replaces image


document.addEventListener('DOMContentLoaded', function() {
$j( function() { // ensures that script will run after all content is loaded (jQuery)
var button = document.getElementById('replaceImageButton');
$j('#replaceImageButton').click(function() { // adds an onClick event listener for an element with id=replaceImageButton
button.addEventListener('click', function() {
// Get a reference to the container element by its ID
// Get a reference to the container element by its ID
$j('#containerID').find('img').attr('src', $j('#newImageURL').text()); // equivalent to 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.find('img');
var imageElement = container.querySelector('img');


// Replace the image source with a new one
// Replace the image source with a new one
imageElement.src = $j('#newImageURL').text(); // requires an element with the newImageURL ID (may be display:none)
imageElement.src = getElementByID('newImageURL');
*/
});
});
});
});