Answers for "Property 'style' does not exist on type 'Element'"

0

Property 'style' does not exist on type 'Element'.ts(2339)

// Cast to the type of `HTMLElement`
const el = document.getElementById('whatever') as HTMLElement;
el.style.paddingTop = ...;

// Or, if it is an array
const els = document.getElementsByClassName('my-class') as HTMLCollectionOf<HTMLElement>;
Posted by: Guest on August-09-2021
0

Property 'style' does not exist on type 'Element'

const node = document.querySelector<HTMLElement>(element);
Posted by: Guest on August-31-2021

Code answers related to "Property 'style' does not exist on type 'Element'"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language