I have a WordPress site that is using a theme to create some pages. Unfortunately, its creating an H1 in a location I cant edit (only the text, "Home" in this case) and I would like to add my own H1 in another text block location. I'd like to programmatically remove the first H1 and I can do this for H1s (sample page I built by changing it to "body") with this code. (I set i to 0 to only replace the first instance):
<script>
const hTwos = document.querySelectorAll('h1');
for (let i = 0; i < hTwos.length; i++) {
hTwos[0].outerHTML = hTwos[i].outerHTML.replace(/h1/g,"body");
};
</script>
However, when there is a class assigned to the H1 the code does not remove it? Is there a way to remove the HTML code for <h1 class="header-section__title">Home</h1>
from the page using jscript?
Any help would be greatly appreciated.