https://lp.freelance.nl/verzekeren

window.onload = function() {

    var buttons = document.querySelectorAll('.btn-wrp .hs-cta-embed');
    if (buttons.length > 0) {
        var wrapper = document.createElement('div');
        wrapper.className = 'button-wrapper';
        buttons[0].parentNode.insertBefore(wrapper, buttons[0]);
        buttons.forEach(function(button) {
            wrapper.appendChild(button);
        });
    }

    //     ===========

    (function () {
        const paragraphs = document.querySelectorAll('.section .btn-wrp p');

        // Loop through the paragraphs
        if (paragraphs.length > 0){
            for (let i = 0; i < paragraphs.length; i++) {
                const currentP = paragraphs[i];
                const nextP = paragraphs[i + 1];

                // Check if the current p has a span with "hs-cta-wrapper" class and the next p has an anchor tag
                if (currentP.querySelector('span.hs-cta-wrapper') && nextP.querySelector('a')) {

                    console.log(currentP.querySelector('span.hs-cta-wrapper'))
                    console.log(nextP.querySelector('a'))

                    // Create a new div element
                    const newDiv = document.createElement('div');

                    // Clone the currentP and append it to the new div
                    newDiv.appendChild(currentP.cloneNode(true));

                    // Append the next p to the new div
                    newDiv.appendChild(nextP);

                    // Replace the current p with the new div
                    currentP.parentNode.replaceChild(newDiv, currentP);
                }
            }
        }
    })();

};