Search code examples
javascriptphpsimple-html-dom

Php simple html dom remove div with specific class


I am using the code bellow to get some content. My problem is that i don't know how to avoid/bypass/remove a specific div.

html Structure:

<div class="post-single-content box mark-links">
<div class="sharebar-wrap">dfdfdfd</div>
</div>

And i an using the code bellow to get the content:

foreach($html->find('div[class=post-single-content box mark-links]') as $table)
{
$arr44[]=  $table->innertext ;
}

How can avoid or remove or bypass to grab the div with class sharebar-wrap? I don't need it!

Cheers!!


Solution

  • You can indeed use jQuery as Héctor E mentioned, otherwise you can use raw javascript :

    document.querySelector('.sharebar-wrap').remove();