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

117
Visualizações
Problema con la actualización de innerHMTL con el indicador de javascript en la carga

Estoy intentando actualizar la etiqueta con id = "contenido" con información solicitada. Por alguna razón, la función window.onload no funciona. He intentado mover el alrededor sin éxito. Aparentemente, el div es nulo, pero no estoy seguro de cómo remediarlo. ¡Gracias!

 <!DOCTYPE html> <html lang="en"> <head> <title>Exercise 3</title> <meta charset="UTF-8"> </head> <body> <p><strong>User Information:</strong></p> <div id=”content”>...</div> <script type="text/javascript"> function promptFunc() { let text; let name = prompt("What is your full name?", "Name"); let age = prompt("How old are you?", "Age"); if (name == null || age == null || name == "" || age ==""){ text = "User did not enter information"; }else { text = "Hi, my name is "+name+" and i'm "+age+" years old."; } document.getElementById("content").innerHTML = text; } window.onload=function(){ promptFunc(); } </script> </body> </html>

about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

Su código tiene un error en las comillas de "contenido" . ha dado las comillas incorrectas en div id="content">

 <!DOCTYPE html> <html lang="en"> <head> <title>Exercise 3</title> <meta charset="UTF-8"> </head> <body> <p><strong>User Information:</strong></p> <div id="content">...</div> <script type="text/javascript"> function promptFunc() { let text; let name = prompt("What is your full name?", "Name"); let age = prompt("How old are you?", "Age"); if (name == null || age == null || name == "" || age ==""){ text = "User did not enter information"; }else { text = `Hi, my name is ${name} and i'm ${age} years old.`; } document.getElementById("content").innerHTML = text; } window.onload=function(){ promptFunc(); } </script> </body> </html>
about 4 years ago · Santiago Gelvez Relatório

0

<!DOCTYPE html> <html lang="en"> <head> <title>Exercise 3</title> <meta charset="UTF-8"> </head> <body> <p><strong>User Information:</strong></p> <div id="content">...</div> <script type="text/javascript"> function promptFunc() { let text; let name = prompt("What is your full name?", "Name"); let age = prompt("How old are you?", "Age"); if (name == null || age == null || name == "" || age == "") { text = "User did not enter information"; } else { text = "Hi, my name is " + name + " and i'm " + age + " years old."; } document.getElementById("content").innerHTML = text; } window.onload = function() { promptFunc(); } </script> </body> </html>

Utilice las comillas dobles ("") en id="contenido"

about 4 years ago · Santiago Gelvez 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