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

75
Views
JS Return HTML Title as H1 Headline

first of all: I‘m not a coder!

I want to inject a dynamic h1 based on page title on a webpage.

Example: <title>Garden</title>

Now I need this as H1 class - I want to include this H1 after a given div class <div class="teaser"></div>

It is may totally simple and I already read some stuff but i don‘t get it…

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

0

Fairly trivial

window.addEventListener('DOMContentLoaded', function() {
  const h1 = document.createElement('h1')
  h1.innerHTML = document.title;
  document.querySelector(".teaser").insertAdjacentElement("afterend", h1)
})
<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title>Garden</title>
</head>

<body>
  <div class="teaser">Teaser</div>
</body>

</html>

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!