var imgs = document.querySelectorAll("[name=NameJPG]"); for (var i = 0, len = imgs.length; i < len; i++) { imgs[i].style.display = "none"; }