Let's say I've got a DOM element - how can I tell if it matches a jquery selector, such as "p" or ".myclass"? It's easy to use the selector to match children of the element but I want a true/false, does this particular element match?
The element may not have an ID (and I can't assign it a random one for reasons beyond this), so I can't apply my selector to the element's parent and look for children with the same ID as mine.
Will this work as intended? I can't figure out Javascript object comparisons.
$(selector, myElement.parentNode).each(
{
if (this == myElement) // Found it
});
Seems like there would be an easy way to see if a DOM element matches a jquery selector...