3

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

'click' does not exist on type 'Element'

document.body.querySelector(".class").click();

1 Answer 1

15

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();
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you that solve my problem, my question was short because it doesn't need more details I wanted just to add this trigger click on a simple method

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.