window.onload = function() { var a = document.getElementById("JPG1") a.onmouseover = function() { var imgs = document.getElementsByName('NameJPG'); for (var i = 0, len = imgs.length; i < len; i++) { imgs[i].style.display = "none"; } } }