jQuery nth-child add html after

前端 未结 1 1956
情深已故
情深已故 2020-12-31 10:03

I have a simple unordered list with 16 list items. I want to add a new list item after every fourth existing list item using jQuery

How would I do that? Code below:<

1条回答
  •  温柔的废话
    2020-12-31 10:20

    Using the :nth-child selector (documentation):

    $('ul li:nth-child(4n)').after('
  • This is what I want to add
  • ')

    0 讨论(0)
提交回复
热议问题