let bodyElement = document.querySelector('body.index'); let targetSection = document.querySelector('.c-own-section'); let headerElement = document.querySelector('header'); let customeSection = document.createElement('section'); customeSection.classList.add('special-section'); customeSection.innerHTML = `
`; if (bodyElement) { if (targetSection) { targetSection.after(customeSection); } else { headerElement.after(customeSection); } }