So is $('table.selectable td.capable input:text') preferable to $('table.selectable td input:text')? In other words, does specifying a class speed up or slow down the selection (assuming it isn’t absolutely required in this scenario)?
So is $(‘table.selectable td.capable input:text’) preferable to $(‘table.selectable td input:text’) ? In other words,
Share
I did not check the Sizzle implementation, but in the best case,
tdwould map to something like getElementsByTagName() and.capableto something like getElementsByClassName(), if available. So both would be comparable in terms of speed.However, there is no
getElementsByTagNameAndClassName()method as far as I know, so resolvingtd.capableprobably requires an additional filtering pass after the DOM call. So, I’m quite inclined to think it would be slower.Naturally, a benchmark would tell for sure.