Below is the code snippet to change the style of elements:
const test = Array.from(document.getElementsByClassName('mat-form-field-infix'));
test.forEach((element) => {
element.outerHTML = '<div class="good-day-today" style="width: 0px;"></div>'; // This line is functioning correctly!
element.style.padding = '10px';
element.style.borderTop = '0';
});
The error message I encounter during compilation states:
ERROR in src/app//.component.ts(101,21): error TS2339: Property 'style' does not exist on type 'Element'. src/app//.component.ts(102,21): error TS2339: Property 'style' does not exist on type 'Element'.
Any suggestions on how to resolve this issue?
I have attempted various approaches such as removing the Array.from...
section, using for of
and for in
, utilizing as any
, but none seem to be working except for the current method.