-1

Code:

<div id="a787656" class="a r">
  <a class="p online" href="/66666" rel="author nofollow" itemscope="" itemtype="http://schema.org/Person">
    <img src="https://m.photo.com" width="64" height="64" alt="Noname" itemprop="image" loading="lazy">    <div class="name" itemprop="name">Noname</div>
  </a>
  <div class="cont">
    <p style="background:#e8f4eb" data-href="/a/787656">Yes</p>

I already tried deleting everything with document.getElementsByName but it didn't work.

Grave
  • 1
  • 4
    If you tried something, then a.) *show us the code* that you tried and b.) be slightly more descriptive of what "didn't work" means, it's a basically useless description. What happened? Any error log messages? – Joachim Sauer Sep 14 '22 at 13:07
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 14 '22 at 14:08

1 Answers1

1

The selector you are after is [href='/66666'] and the universal method for this kind of things is querySelectorAll (or querySelector).

document.querySelectorAll("[href='/66666'], p[style]").forEach(function(elem) {
  elem.remove();
})
<div id="a787656" class="a r">
  <a class="p online" href="/66666" rel="author nofollow" itemscope="" itemtype="http://schema.org/Person">
    <img src="https://m.photo.com" width="64" height="64" alt="Noname" itemprop="image" loading="lazy">
    <div class="name" itemprop="name">Noname</div>
  </a>
  <div class="cont">
    <p style="background:#e8f4eb" data-href="/a/787656">Yes</p>
    
    i'm last
    
IT goldman
  • 14,885
  • 2
  • 14
  • 28
  • I'm sorry, but the script still doesn't work correctly. It now removes all hrefs that start with "p style", and I want it to only remove the content of that tag that has href="/66666" in the div, no others. I need to remove everything that starts with href="/66666" and ends with . – Grave Sep 14 '22 at 14:49