jQuery nth-child add html after

前端 未结 1 1955
情深已故
情深已故 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('<li class="clear">This is what I want to add</li>')
    
    0 讨论(0)
提交回复
热议问题