I have a generic jQuery selector (a string):
var selector = '#files li div';
and the name of a class:
var myClass = 'folder';
I want to check if the selector matches elements having the class stored into myClass. As far as now I used an instance of the selector to invoke the method hasClass():
var match = $(selector).hasClass(myClass);
It works, but I thought it may exist some more efficient jQuery method which allows not to create a jQuery instance to get all the elements matched by the selector.
My worry is the memory used by the instance created only for this check and nothing more, althought it is inside the method of a pseudo-class which does not return/expose any reference to this instance.
Can you suggest something better?
<EDIT>
In the example showed I set the value of myClass to "folder" just to easily represent the problem, but in the app I do not know it in advance, since it is defined by user actions.
</EDIT>