diff --git a/blocks/contactus/contactus.js b/blocks/contactus/contactus.js index 8333e3f..8cdf7ce 100644 --- a/blocks/contactus/contactus.js +++ b/blocks/contactus/contactus.js @@ -13,18 +13,19 @@ export default function decorate() { let phone = ''; for (let i = 0; i < pTags.length; i += 1) { if (i === 0) { - const ContactUsTitle = pTags[i].outerHTML.replace(/

/g, '

'); - innerElements += ContactUsTitle.replace(/<\/p>/g, '

'); + const contactUsTitle = pTags[i].outerHTML.replace(/

/g, '

'); + innerElements += contactUsTitle.replace(/<\/p>/g, '

'); } else if (i === 1) { innerElements += pTags[i].outerHTML; - } else if (i === 3) { - const contactNumber = pTags[2].innerHTML.trim(); - const contactNumberReplace = contactNumber.replace(/[()-\s]/g, ''); - phone = pTags[2].outerHTML.replace(/

/g, ``); - phone.replace(/<\/p>/g, ''); - pTags[i].innerHTML = `

${phone + pTags[i].innerHTML}
`; - const button = pTags[i].outerHTML.replace(/

/g, ''); - innerElements += button.replace(/<\/p>/g, ''); + } else if (i === 2) { + phone = pTags[i].innerText; + const anchor = document.createElement('a'); + anchor.classList.add('phone'); + anchor.setAttribute('href', `tel:${phone}`); + anchor.innerText = phone; + innerElements += anchor.outerHTML; // Use anchor.outerHTML here + } else { + innerElements += pTags[i].outerHTML; } } contactUsDiv.innerHTML = innerElements;