-2

I would like to change the title of my page based on the name of

for example, <h1>lorem imsum<h1> would set the page title to lorem ipsum

internetoscar
  • 23
  • 1
  • 4

1 Answers1

0

Assuming you want to do it in JS

document.title = document.querySelectorAll('h1')[0].textContent

Where [0] is indicating that you want the text from the first h1 element. If your h1 will have an id then use that instead as it will explicit therefore safer.

Marco Yammine
  • 303
  • 1
  • 10