Could someone tell me how could I change the value with HTML code to a regular string? Example:
<h1>Hello world!</h1>
=> "<h1>Hello World!</h1>"
Current code:
var myH1 = document.getElementsByTagName("h1")[0];
console.log(myH1);
// Prints: <h1>Hello World!</h1> instead of "<h1>Hello World!</h1>"
<h1>Hello World!</h1>
myH1is a HTMLElement (object). Why do you expect it to be a string?myH1.outerHTML