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

103
Visualizações
How to place html tags inside javascript string?

I have this code right here:

generation.innerHTML=
"<!DOCTYPE html>\n"+
"<html>\n"+
 "<head>\n"+
  "<style>\n"+
   cinput+
  "\n<\/style>"+
 "\n<\/head>"+
 "<body>\n"+
  hinput+
  "\n<script>\n"+
   jinput+
  "\n<\/script>\n"+
 "<\/body>"+
"<\/html>";

But the doctype, html, head and body tags dissapear when I console log it, but when viewing it as a P element, all of the tags go away and leave the hinput, cinput, jinput variables.

How do I make all of it stay when viewing as a P element?

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

0

innerHTML tries to parse the data as HTML. Hence the name.

If you want to treat it as plain text, use textContent instead.

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