Aniket Singh Aniket Singh - 1 year ago 70
CSS Question

How to remove div with a particulart text in it

I have some div which has some text & elements in it & i want to remove those div, those div look like this

<div style="font-family:verdana;font-size:12px;">Example<a href="" title="hey">example</a></div>

there are many div like this & i want to remove them with jquery or javascript

Answer Source

Based on Darren's answer, if you want to be extra sure (as :contains will match and delete any div containing the word example), you can make sure it's a div that has an anchor with that same example as children, then go back to the parent and remove it.

If this doesn't work, please paste a few more divs so we can see a common pattern and target it the safest way possible.


<script src=""></script>
<div style="font-family:verdana;font-size:12px;">Example<a href="" title="hey"> example</a></div>
<div style="font-family:verdana;font-size:12px;">Don't remove<a href="" title="hey"> example</a></div>
<div style="font-family:verdana;font-size:12px;">Example<a href="" title="hey"> don't remove</a></div>

<button id="remove">
Remove undesired divs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download