I tried to create a new HTML element, called test: <test>some text</test>
I tried to prototyping it like this: HTMLUnknownElement.prototype.style.backgroundColor = "red";
but it doesn't work.
Could you please help me, how to manage it?
Thanks in advance,
How about createElement()
?
var el = document.createElement("test");
el.style.backgroundColor = "red";
document.body.appendChild(el);
If we start with:
<html>
<head></head>
<body>
</body>
</html>
The result will be:
<html>
<head></head>
<body>
<test style="background-color:red"></test>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With