nach jedem 4ten div ein neuen absatz in javascript

index.tsx
const divs = document.querySelectorAll('div');

divs.forEach((div, index) => {
    if ((index + 1) % 4 === 0) {
        const paragraph = document.createElement('p');
        div.parentNode.insertBefore(paragraph, div.nextSibling);
    }
});
242 chars
9 lines

related categories

gistlibby LogSnag