Is it possible to modify this code so that each text box only shows the text corresponding to its respective image? I am still relatively new to coding and am struggling to achieve the desired outcome.
function displayImageInfo(text) {
document.getElementById("text").innerHTML = text;
document.getElementById("text2").innerHTML = text;
}
function hideText() {
document.getElementById("text").innerHTML = "";
document.getElementById("text2").innerHTML = "";
}
<LINK REL="stylesheet" TYPE="text/css" HREF="test2css.css">
<h1> UFO Test Page </h1>
<img src="ufo.png" id="image" onMouseOver="displayImageInfo('its a ufo baby')" onMouseOut="hideText();">
<div id="text" style="position:absolute; left: 100px; top: 200px;"> </div>
<br>
<img src="alien.png" id="image2" onMouseOver="displayImageInfo('its a grey baby')" onMouseOut="hideText();">
<div id="text2" style="position:absolute; left: 150px; top: 400px;"> </div>