Gladishmare Gladishmare -4 years ago 227
TypeScript Question

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();

Answer Source

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();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download