I need to hide the section from the html page:
<h1 data-ng-show="!menuPinned && !isSaaS" class="logo floatLeft" aria-hidden="false"><span>XXX </span><span style="font-weight: bold;">XXX </span><span>XXXXX</span></h1>
The following code works fine in Chrome dev. tools
var ibmlogo = document.querySelectorAll('h1.logo.floatLeft');
ibmlogo[1].remove();
But when I load the page with the active script, the section (h1) will not disappear. I believe this is because when the script is running, the DOM is not finished yet, so the script cannot find the selector.
I tried many different things (e.g. window.onLoad), but my script is not efficient. The last attempt (unsuccessful) is as follows:
var logo = document.querySelectorAll('h1.logo.floatLeft');
logo.onload = function() {removeLogo()};
function removeLogo(){
console.log("### logo array lenght: " + logo.length);
logo[1].remove();
};
Any tips? Thanks Giovanni
source
share