Este fragmento de código está destinado a llamar a una función, llamada "verificar ()" y devolver un valor dependiendo de si ciertos botones de opción están marcados, en el elemento span con 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>Sin embargo, cuando se llama a "verificar()", devuelve el código de error: "Error de tipo no detectado: la verificación no es una función".
No parece ser un error tipográfico, como lo que puedo ver hasta ahora.
¿Algunas ideas?
El nombre de su función es el mismo que el de la variable, solo elija un nuevo nombre para la función