I am trying to remove empty H1 tags from my FE environment using JS. After I remove it bots and crawlers still see these tags = they are still visible via Page Source, the DOM nodes are loaded ect..
Is there a way to completely remove an element from the DOM?
My html is this:
<a href="/link"><img src="banner.jpg" title="Title" />
<h1 class="nivo-h1-title">
<span></span>
</h1>
</a>
Firstly i tried jQuery method:
$( document ).ready(function() {
$( ".nivo-h1-title" ).remove();
});
This way the elements are removed from final HTML but still are present when you view the page via Page Source and Robots / Crowlers still see them. I researched a lot and tried pure Javascript method using code from this link Remove all child elements of a DOM node in JavaScript - removeChild with parentNode:
var elements = document.getElementsByClassName('nivo-h1-title');
while(elements.length > 0){
elements[0].parentNode.removeChild(elements[0]);
}
But alas the html elements are still in the DOM = still can be seen via Page Source.
I already checked this Completly remove a tag from the source and others, but IS there a way to do this - completely remove elements from source?