tengo el siguiente HTML
Código :
<html> <head> <script language="javascript" src="funciones.js" type="text/javascript"></script> <style> img{width:100px;height:100px;margin-top:20px;} table{background-color:black;} </style> </head> <body> <center> <table> <tr> <td><img src="1.jpg"></td><td><img src="2.jpg"></td><td><img src="3.jpg"></td><td><img src="4.jpg"></td> </tr> </table> </center> </body> </html>
y este java
Código :
window.addEventListener('load',inicializarEventos,false); function inicializarEventos(e) { var vec=document.getElementsByTagName('img'); for(i=0;i<vec.length;i++) { vec[i].addEventListener('mouseover',presionar,false); vec[i].addEventListener('mouseout',soltar,false); } } function presionar(e) { var objeto=e.target; objeto.style.marginTop='0px'; } function soltar(e) { var objeto=e.target; objeto.style.marginTop='20px'; }
Y quiero hacer que cuando ponga el mouse sobre la imagen '2' tambien reaccionen las imagenes '1' y '3' con un margin de 10px.