you would imagine this would be easy to implement, but oh well..
anyway, I have an element to which classes are added or removed based of interaction on the site.
<
Use classList
property on the HTML Element:
document.getElementById("mydiv").classList.length
document.querySelector("#mydiv").classList.length
$("#mydiv").prop('classList').length // jQuery method.
The classList
gives the array of classes present for the element. So, .length
will say if there's any class there.