I heard it was better to put the Javascript in an external file and call it from the html file. However, I tested some code and it does not work when it is an external file, although it does work fine when it is inline in the html file.
Here is the code:
var bigImage = document.getElementById(‘zoom’);
var smImage = document.getElementById(‘thumbnail’);
smImage.onclick = function() {
if(bigImage.style.display === “block”) {
bigImage.style.display = “none”;
}
else {
bigImage.style.display = “block”;
}
}
Any idea why it only works inline?