Please I want to hide that contains a link sabdel.com .
I used the below javascript code but it doesn\'t work
First of all, you are incorrectly using addEventListener
. Second, you must check the href
attribute, not innerHTML
:
window.addEventListener("yourEvent", () => {
var elem=document.querySelectorAll("a");
for(var i = 0; i < elem.length; i++) {
if(elem[i].href.includes('sabdel.com')) {
elem[i].style.display="none";
}
}
}
Replace yourEvent
with the event you want to listen with. For example, if you are listening for a click event, replace it with click
.
Do you mean like this ?
window.addEventListener = () => {
var tags = document.getElementsByTagName("a");
for (var i = 0; i < tags.length; i++) {
var attributeValue = tags[i].getAttribute('href');
if (attributeValue.includes('sabdel.com')) {
tags[i].style.display = 'none';
}
}
}