Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

querySelector with trigger click not working into angular 2

querySelector not working with click() method on angular it throws compilation error :

'click' does not exist on type 'Element'

document.body.querySelector(".class").click();
like image 684
Gladishmare Avatar asked Jan 21 '26 11:01

Gladishmare


1 Answers

Your question is missing a lot of details but can you try to explicitly cast it as an HTMLElement:

let yourElem= <HTMLElement>document.querySelector('.class');
yourElem.click();
like image 188
Hamed Baatour Avatar answered Jan 26 '26 10:01

Hamed Baatour



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!