Possible Duplicate:
How can I tell whether an element matches a selector?
I’ve been using jQuery for this javascript framework I’ve been working on and I was wondering if there is a way of checking if a given selector matches a given jQuery object. Something like:
var divObj = $(document.createElement('div'));
var result = divObj.hasSelector('div');
Result would either return a “true” or the object back if the selector matches the object.
You can tell if an object is a div using:
Or for a direct comparison: