Estoy usando este script:
<html> <script> function hover(element) { element.setAttribute('src', 'http://dummyimage.com/100x100/eb00eb/fff'); } function unhover(element) { element.setAttribute('src', 'http://dummyimage.com/100x100/000/fff'); } </script> <img id="my-img" src="http://dummyimage.com/100x100/000/fff" onmouseover="hover(this);" onmouseout="unhover(this);" /> </html>Cambiaré la fuente de la imagen pero quiero fijar el ancho a 120px. ¿Cómo puedo hacer esto?
Usando el atributo de estilo
element.style.width = '120px';
y también puede agregar mucho más estilo con el mismo atributo como relleno, margen, tamaño de fuente, etc.