I possess a pair of images:
<img id="img1" src="l1.jpg" usemap="#lb" height="400" border="0" width="300">
<img src="images.jpg" id="img2">
Next up is some JavaScript:
function validateImages () {
if (document.getElementById('img2').src=="images.jpg")
{
if (document.getElementById('img1').src=="l1.jpg")
{
window.alert("hello");
}
} else {
window.alert("goodbye");
}
}
validateImages();
Furthermore, there is a button that triggers the function:
<button type="button" onclick="validateImages()">Click Here!</button>
Despite both images having their sources set as defined in the script, it continues to display 'goodbye' instead of 'hello'. What could be causing this issue?