Assuming I have this structure in my code:
<div>
<div>This is my text</div>
<div>Text continues...</div>
</div>
<div>
<div>Another text</div>
<div>Other text</div>
</div>
<div>
<div>This is my text</div>
<div>Text continues...</div>
</div>
What I'm trying to do is (with no jquery):
Search for this is my (realize that I'm not passing the full text. Just a part of it this is my).
And everytime I find a div that contains this part of text, I want to remove the parent div! Consequently, by removing everything within it, which includes:
<div>This is my text</div>
and
<div>Other text</div>
So as a result, I would have only this:
<div>
<div>Another text</div>
<div>Other text</div>
</div>
I tried this way:
var elems = document.querySelectorAll("div"),
res = Array.from(elems).find(v => v.textContent == 'Vídeos que contêm');
alert(res ? 'found!' : 'not found');
But it searches for specific text! And it still does not work for every occurrence.