I'm trying to change the innerHTML of H1 tags on multiple pages on my site using GTM. The site I'm working on currently takes the H1 from the URL slug and I am unable to edit the H1 directly in the CMS. I figured If statements would be the way forward, changing multiple H1 tags across different pages by stating the current H1 tag and if it matches, changing it to what I want it to display. I've been testing in the console.
Here what I have so far:
document.getElementsByTagName('h1')[0].innerHTML
if ('h1')[0].innerHTML = "This" .innerHTML ="That";
This works correctly in the console, but doesn't change anything on the page so clearly it's not working .
I am not at all experienced with Javascript and am not particularly tech-minded so please bear this in mind with any answers :)
document.getElementsByTagName('h1')[0].innerHTML
if ('h1')[0].innerHTML = "This" .innerHTML ="That";
Aucun commentaire:
Enregistrer un commentaire