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

99
Views
Javacript [ document.write ("___"); ] Shortcut to not start each line with document.write ("

In this code I want to insert some HTML and normal text in JavaScript and don't want it to always enter document.write(" in starting of each line like:

document.write("some text
some text
some text");

Instead of this:

document.write("Hello World!");
document.write("Have a nice day!");
document.write("<br>");
document.write("<p>some random paragraph");

document.write("Hello World!");
document.write("Have a nice day!");
document.write("<br>");
document.write("<p>some random paragraph");

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

  1. Don't use document.write:

⚠ Warning: Use of the document.write() method is strongly discouraged.

  1. Use a template/string to create the HTML, and then assign it to the innerHTML of the document body (or whatever element you want).

document.body.innerHTML = `
  Hello World!<br />
  Have a nice day!<br />
  <p>some random paragraph</p>
`;

about 4 years ago · Juan Pablo Isaza Report

0

⚠Warning: Don't use document.write


Instead use document.body.innerHTML = '';

document.body.innerHTML = `
your text
<br>
your text
`;

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!