I would like to check if a variable exist in the dom and receive a true false answer.
I try this command:
document.body.contains(document.querySelectorAll('div.grid'))
but it is not working
any idea how can I change to have the right option?
Advertisement
Answer
const containsElement = document.querySelectorAll('div.grid').length !== 0