Example fully defined in JS

const NBalloon = 100;
const bodyElement = document.querySelector('body');
for(let k = 0; k < NBalloon; k++) {
  const newImage = document.createElement('img');
  newImage.src = 'balloon.jpg';
  bodyElement.appendChild(newImage);
  newImage.addEventListener('click', actionExplode);
}

function actionExplode(event) {
  event.currentTarget.src = 'bang.jpg';
}