Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing style of getElementsByClassName gives compile error

I am trying to change the style of all of the elements which I received by calling the method getElementsByClassName. The thing is that it does work when it has compiled before (I commented these rows out to let it compile), it just says the error in the cmd. After it compiled I just set the lines back to normal, they keep giving errors but are working in the browser. Any thoughts on this weird behavior?

enter image description here

enter image description here

When commented out:

enter image description here

When not commented and giving errors:

enter image description here

like image 306
BrianM Avatar asked Nov 25 '25 10:11

BrianM


1 Answers

I think the problem is with TypeScript. You should try this workaround

var texts = document.getElementsByClassName("section_text") as HTMLCollectionOf<HTMLElement>;
like image 165
Leo Odishvili Avatar answered Nov 26 '25 23:11

Leo Odishvili



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!