doon
doon

Reputation: 2361

Can the root element HTML in the DOM be replaced in javascript

I am a beginner in javascript. As mentioned in stack overflow query, I can remove or create elements within the DOM. However, can I replace the root element through javascript e.g. if I want to change an attribute of the HTML element through javascript?

Upvotes: 4

Views: 2499

Answers (1)

sesamechicken
sesamechicken

Reputation: 1981

I think you're asking if you can modify the element, and the answer is yes.

var html = document.getElementsByTagName('html')[0];
html.title = "Foo"; // Set an attr on the element

Upvotes: 4

Related Questions