jQuery difference between :eq() and :nth-child()

前端 未结 8 2353
一个人的身影
一个人的身影 2020-12-02 15:26

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

8条回答
  •  一生所求
    2020-12-02 16:26

    $("#dataTable tr:nth-child(1) td:nth-child(2)").html();
    

    here dataTable is a table

    Name EnrollNo.
    SomdipIT001
    SanyalIT002

    The nth-child selector of jquery will help you to fetch the exact cell values from this table. A practical example where tr:nth-child(1) td:nth-child(2) fetches the 1,2 cell of the table.

提交回复
热议问题