9 - Otras formas de acceder a los nodos hijos (firstChild - lastChild)


Definir un div con tres párrafos. Cambiar el tamaño de fuente del primero y el último.
<html>
<head>
<title>Problema</title>
<script language="javascript" src="funciones.js" type="text/javascript"></script>
</head>
<body>
<div id="bloque"><p>Este es el primer párrafo</p><p>Este 
es el segundo párrafo</p><p>Este es el tercer párrafo</p></div>
<input type="button" value="Cambiar tamaño de fuente del primer y último párrafo" onClick="cambiarTamanoFuente()">
</body>
</html>
function cambiarTamanoFuente()
{
  var punterodiv=document.getElementById('bloque');
  punterodiv.firstChild.style.fontSize='30px';
  punterodiv.lastChild.style.fontSize='30px';
}

Ver solución
pagina1.html



funciones.js