Not going to native methods I'd say the fastest selector without an ID
would be $("#tableid td.cellclass") as that will call getElementByID
and getElementsByTagName/getElementsByClassName from the #tableid
context (or querySelectorAll). Anyway, you only need to add more
selectors if you want to enforce the relationships, the more of them
the slower it gets.

For IDs you should always use just the element's ID. Anything that
comes before it will consume parsing time needlessly if the ancestors
are not important.

- ricardo

On Feb 16, 4:30 am, SteelRing <steelr...@gmail.com> wrote:
> This may sound stupid to y'all jquery practitioners, but i wonder
> which method is fastest (recommended) for selecting a cell with a
> class in a big table (think like 1000+ rows 100+ columns):
>
> ("#tableid tbody tr.rowclass td.cellclass") or is it ("td.cellclass")
> or (".cellclass").
>
> And how about if the cell happens to have a unique id:
>
> ("#tableid tbody tr#uniquerow td#uniqueid") or just ("#uniqueid")
>
> Philosophically, the question being is it better to put as much detail
> as structurally already known by the programmer into the selector or
> just anything goes and let jquery handle it as long as it works.

Reply via email to