More on jQuery selectors

Following up on my 13 seconds of selection hell:
jQuery: what are the fastest selectors?
Turns out that, as you might expect, $(’div.class’) is faster than $(’.class’), and so is $(’div’).filter(’.class’). Knowing where not to look (”skip anything that’s not a div”) helps make jQuery faster. To which you might say, “well duh.” Regardless, the post above […]

13 seconds: Attribute vs. ID selectors in jQuery

Before:
 
// select all elements with an id or name attribute of fieldName;
// some are inputs (name attribute), some are td’s (id attribute)
var $field = $(’#’ + fieldName + ‘, [name=’ + fieldName + ‘]’);
 
After:
 
// give inputs both a name and an id attribute,
// and then just select fields and td’s via id
var $field = $(’#’ […]