Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
"Uncaught TypeError: check is not a function" no typo html website

This piece of code is meant to call a function, named "check()" and return a value depending if certain radio buttons are checked, in the span element with id "ans".

<head>
    <script>
    var check = 0
    function check() { // Where the function is set
        if (document.getElementById("hig").checked) {
            check+=1
        }
        if (document.getElementById("med").checked) {
            check+=1
        }
        if (document.getElementById("low").checked) {
            check+=1
        }
        document.getElementById("ans").textContent="You got " + check + "/3"
    }
    </script>
    </head>
    
    <body>
    <center>
    <h2>What radiation does:</h2>
    <h3>Penetrating Power:</h3>
    Alpha Radiation: <span id="a"></span> <br>
    <input type="radio" name="a" id="hig">
    <input type="radio" name="a" id="med">
    <input type="radio" name="a" id="low"> <br>
    
    Beta Radiation: <br>
    <input type="radio" name="b" id="hig">
    <input type="radio" name="b" id="med">
    <input type="radio" name="b" id="low"> <br>
    
    Gamma Radiation: <br>
    <input type="radio" name="g" id="hig">
    <input type="radio" name="g" id="med">
    <input type="radio" name="g" id="low"> <br>
    
    High/Medium/Low <br>
    <button onclick="check()">Check</button> <!--Where the function is called-->
    <span id="ans"></span>
    </center>
    </body>

However, when "check()" is called, it returns the error code: "Uncaught TypeError: check is not a function".

It doesn't seem to be a typo, as what I can see so far.

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your function name is the same name as the variable, just pick a new name for the function

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda