Solución al ejercicio propuesto CU01157E del curso avanzado de programación web con JavaScript:
<!DOCTYPE html>
<html>
<head>
<title>eventos</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" >
window.onload = function () {
var nodos = document.querySelectorAll('h1, h3');
for (var i=0; i<nodos.length; i++) {
nodos[i].onmouseover = function() {
this.style.color = "orange";
}
nodos[i].onmouseout = function() {
this.style.color = "maroon";
}
}
var nodosP = document.querySelectorAll("p");
for (i in nodosP) {
nodosP[i].onmouseover = function () {
this.style.backgroundColor = "yellow";
}
nodosP[i].onmouseout = function () {
this.style.backgroundColor = "transparent";
}
}
}
</script>
</head>
<body> <p><a href="principal.html" title="Página principal" >Ir a la pagina principal</a></p>
<h1>Novedades</h1>
<p>Aquí presentamos las novedades del sitio.</p>
<h3>Lanzamos el producto X-FASHION</h3>
<p>Este producto permite estirar la piel hasta dejarla como la de un bebé.</p>
<p><img src="http://i.imgur.com/tq5Bs.png" title="Imagen del producto" alt="imagen producto x-fashion" /></p>
<h3>Mejoramos el producto T-MOTION</h3>
<p>Hemos lanzado una nueva versión del producto T-MOTION</p>
<p><img src="http://i.imgur.com/SpZyc.png" title="Imagen del producto tmotion" alt="imagen producto tmotion" /></p>
</body>
</html>