Based on testing a page with ~220 elements, of which ~200 are checkbox elements, and each element has to query an array with ~200 items, I was surprised to discover that input selector:
$("input[id$='" + code + "']").each(function() { //...
is approximately 4-5 times faster than
$("input:checkbox[id$='" + code + "']").each(function() { //...
and approximately 10 times faster than a checkbox selector:
$(":checkbox[id$='" + code + "']").each(function() { //...
Also tried universal selector *
, which performed about the same as input
.
I'm curious to understand why such a big difference in performance?