In jQuery, what are some of the key differences between using :eq() and :nth-child() to select any elements ?
Also in general, for the starting index, in which case does it start from "0" and when it starts from "1" ?
In jQuery, what are some of the key differences between using :eq() and :nth-child() to select any elements ?
Also in general, for the starting index, in which case does it start from "0" and when it starts from "1" ?
nth-child selects the nth child of parent object(s) other selects n-th element in a collection (index starting from 0 or 1 is only a trivial part the difference). so saying tr td:nth-child(5) selects every tr and gets their 5th children where as eq gets all tds in all trs and selects only 5th td ... The main difference is that. Indeed the wording of the documentation does not point out that fact straight but garbles the words like it is black magic ...
here dataTable is a table
The
nth-child
selector of jquery will help you to fetch the exact cell values from this table. A practical example wheretr:nth-child(1)
td:nth-child(2)
fetches the 1,2 cell of the table.