Wrapping a div around every three divs

前端 未结 3 1150
渐次进展
渐次进展 2021-01-05 12:35

Say I have 6 child divs and they don\'t have unique identifiers:

3条回答
  •  醉梦人生
    2021-01-05 13:30

    This should do it:

    var $children = $('.child');
    for(var i = 0, l = $children.length; i < l; i += 3) {
        $children.slice(i, i+3).wrapAll('
    '); }

    DEMO

提交回复
热议问题