not sure exactly what you are trying to do, but if you just wanted the innerhtml of the first element, you could do something like:
$(".classA, .classB", someElement).html();
since html will act on the first matched element.
Otherwise, I don’t see what is wrong with your method, which works ... I suppose you are just asking for additional knowledge?
I never find the need for: first selectorbut, I would do this, for example:
$(".classA, .classB", someElement).first();
source
share