Bienvenido a la Comunidad de Treehouse

¿Quieres colaborar en errores de código? ¿Tienes errores que necesitan comentarios? ¿Buscas un par de ojos adicionales en tu último proyecto? aquí.

¿Buscas aprender algo nuevo?

Treehouse ofrece una prueba gratuita de siete días para estudiantes nuevos. Obtén acceso a miles de horas de contenido y únete a miles de

Inicia tu prueba gratuita

JavaScript Interactuando con el DOM Respondiendo a Eventos Agregando un Detector de Eventos

Nathaniel Bennett
sello-máscara
.a{fill-rule:evenodd;}techdegree seal-36
Nathaniel Bennett
JavaScript Full Stack Graduado de Techdegree 21,820 Puntos

TypeError: 'undefined' is not a function (evaluating 'document.getELementById("makeItRed")')

recibir error de tipo undefined para .getElementById

app.js
var warning = documento.getElementById(advertencia);
var botón = documento.getELementById(makeItRed);
index.html
<!DOCTYPE html>
<html>
    <head>
        <title>Agregando un Detector de Eventos</title>
    </head>
    <link rel=stylesheet href=style.css />
    <body>
        <div id=advertencia>
            Advertencia: ¡Mi fondo debería ser rojo!
        </div>
        <botón id=makeItRed>¡Hazlo Rojo!</botón>
        <script src=app.js></script>
    </body>
</html>

1 Respuesta

Steven Parker
Steven Parker
244 163 puntos

Este código tiene "getE‍L‍ementById" (con una "L" mayúscula) en lugar de "getElementById".
Dado que JavaScript distingue entre mayúsculas y minúsculas, el sistema ve esto como una función indefinida.