What is the proper way to check if an html element exist in a webpage.
I do like this:
if (document.getElementById('container') !== null) {doThis()}
How good is this? What are other ways?
What is the proper way to check if an html element exist in a webpage.
I do like this:
if (document.getElementById('container') !== null) {doThis()}
How good is this? What are other ways?
Answered
I was looking for
document.body.contains(element))