Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!