JavaScript - Replace the H1/H2 Headings & Paragraphs

Sitebee

Technical SEO
Staff member
Code:
<script>
if (window.location.href.indexOf("URL-Goes-Here") > -1) {
document.querySelectorAll("h1")[0].innerText = "This is a JS rendered H1 headings";
document.querySelectorAll("h2")[0].innerText = "This is a JS rendered H2 heading";
document.querySelectorAll("p")[0].innerText = "Para 1 - Lorem ipsum dolor sit amet, consectetur adipiscing elite.";
document.querySelectorAll("p")[1].innerText = "Para 2 - Lorem ipsum dolor sit amet, consectetur adipiscing elite.";
document.querySelectorAll("p")[2].innerText = "Para 3 - Lorem ipsum dolor sit amet, consectetur adipiscing elite.";
document.querySelectorAll("p")[3].innerText = "Para 4 - Lorem ipsum dolor sit amet, consectetur adipiscing elite.";
}
</script>