I have a working jQuery statement as follows
var firstHeaderLineElement = $(".resultGridTable .tableColGroupAssociate");
I need to make this more generalized by making .tableColGroupAssociate as a variable. I have achieved this using following:
var hideClass = '.tableColGroupAssociate';
var firstHeaderLineElement = $(".resultGridTable").find(hideClass);
However, it requires a “find”. Is there a better performing jQuery way for this?
Using String concatenation:
jQuery
$(selector, context)format:But internally it implements the
.find().Note
But jQuery always not implements the
find()method. In modern browsers it try to implement thedocument.querySelectorAll()so that browser will try to parse it as a valid CSS selector.If this default engine fails then jQuery parse the selector using its default engine Sizzle which using its internal mechanism for DOM traversing.