Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!

like image 612
Irene T. Avatar asked May 02 '26 15:05

Irene T.


2 Answers

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

document.querySelector('.sharebar-wrap').remove();
like image 159
Amen Ayach Avatar answered May 05 '26 05:05

Amen Ayach


With javascript:

var aux = document.getElementByClass('sharebar-wrap');
aux.parentNode.removeChild(aux);

With jQuery: $( ".sharebar-wrap" ).remove()

like image 26
Héctor E Avatar answered May 05 '26 05:05

Héctor E