Skip to content Skip to sidebar Skip to footer

Get All IDL Attributes For An HTML Element

I know it's possible to get all content attributes on a a standard HTMLElement like this: const input = document.querySelector('input'); c

Solution 1:

They exist on the prototype, so you can examine the prototype's JS properties:

const getKeys = obj => obj
  ? Object.keys(obj).concat(getKeys(Object.getPrototypeOf(obj)))
  : [];
console.log(
  getKeys(document.querySelector('input'))
);
<input>

Post a Comment for "Get All IDL Attributes For An HTML Element"