I am trying to figure out what in the world this jquery selector is doing. When it runs, it is executing on a massive scale and removing it increases execution speed by roughly 95%. The optimized code works fine without it, but I am still trying to figure out what it was doing in the first place.
Here is the original code format:
$("[name='" + this.Name + "']", $(document.body))...
The item I’m trying to figure out is what is after the comma. It’s not a normal part of the selector, as it is outside the main batch of quotes, and I have had no luck at all finding documentation on anything like this. When the code is reduced to
$("[name=\"" + this.Name + "\"]")
then it operates at a massively increased speed (95% faster). Does anyone know what that extra $(document.body) is doing?
The 2nd parameter to the
$()function is thecontext. It’s the same as doing:(Which is completely useless as tags aren’t normally outside the body of a document.)
P.S. You don’t need to wrap the 2nd param in
$(), it can be a DOM element (or even a selector).