window.onload = function() { var a = document.getElementById("JPG1") a.onmouseover = function() { document.getElementsByName('NameJPG')[0].style.display = "none"; document.getElementsByName('NameJPG')[1].style.display = "none"; } }