I am trying to apply a event handler to some images in my img folder for some reason it will load the blurred images but will not load the unblurred image when the click handler is invoked.
here is code
window.onload = init;
function init() {
// now we're getting elements from the page using a tag name, img. This finds every image
// in the page and returns them all. We store the resulting images in the images variable
var images = document.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
// Then we iterate over the images, and assign the showAnswer cick handler to each image
// in turn. Now the onclick property of each image is set to the showAnswer handler
images[i].onclick = showAnswer;
}
};
function showAnswer(eventObj) {
var image = eventObj.target;
var name = image.id;
name = name + "img/.jpg";
image.src = name;
}
Aucun commentaire:
Enregistrer un commentaire