Aariba
Aariba

Reputation: 1194

Conditionally Delete html Node

If div .element has specific class .block / <div class="element block"> then delete html node .element img

HTML:

<div class="element">
<img src="images/picture.jpg" alt="" />
<img src="images/picture.jpg" alt="" />
</div>

Want to delete img, how to do this by Jquery?

Upvotes: 1

Views: 49

Answers (2)

Walking.In.The.Air
Walking.In.The.Air

Reputation: 752

Why not something simple like that?

$('.element.block').find('img').remove();

Upvotes: 2

MysterX
MysterX

Reputation: 2368

$('.element.block img').remove () 

This removes only images which are in blocks with the both classes

Upvotes: 2

Related Questions