Add something after the “n” element using jQuery

后端 未结 6 1667
忘了有多久
忘了有多久 2020-12-13 08:49

For a markup like

div 1
div 2
div 3
6条回答
  •  时光取名叫无心
    2020-12-13 09:30

    Try the CSS selector :nth-child():

    $("#holder > div:nth-child(2)").after("
    foobar
    ");

    See also the example on the jQuery page of the :nth-child() selector.

提交回复
热议问题