Hello friends I have this code that works well for me to check if my element contains a certain class, but I want to achieve the opposite, that it checks me when this class does not contain the element.
if (document.querySelector(".header").classList.contains("no-sticky")) {
alert();
}
Just put exclamation mark in front of the condition.
if (!document.querySelector(".header").classList.contains("no-sticky")) {
alert();
}```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With