window.onload=(function(){ var pics=(d=document).getElementsByClassName('pics'); for(i=0;i<=(pics.length-1);i++){ pics[i].onmouseover=(function(){ alert(this.getAttribute('src')); }); } });