1

What is the best way to loop through elements like document.querySelectorAll('.calendar-table td .available') or className using Typescript?

I found many answers using Javascript but some of them with clearer code wasn't supported with all browsers (.forEach for examp but since Typescript compiles back to javascript, then there should be some nice solution working with all browsers? Thank you

1 Answer 1

1

Just use Array.from e.g. const arr = Array.from(document.querySelectorAll('.calendar-table td .available')) and use your standard loops e.g. .forEach etc.

More

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.