0

I've known about this for a while, but I'm not exactly sure what it's called:

var el = document.createElement("p");
el.innerText = "Hello";
el.loremipsum = "TEST STRING"; <-- THIS

document.body.appendChild(el);

If I inspect the DOM, this is what I get:

<p>Hello</p>

The loremipsum property is not in the DOM, but:

document.querySelector("p").loremipsum

returns "TEST STRING". What is this property manipulation called? I would like to research it a bit. And yes, I know data attributes are better to use.

MortenMoulder
  • 6,138
  • 11
  • 60
  • 116

0 Answers0