user1685565
user1685565

Reputation: 337

Remove <br> in a specific div class

I want to remove all <br> tags in the div class category alternate but for some reason I can't get it work.

Here is what I got so far:

$('div.category alternate').find('br').remove();

Upvotes: 1

Views: 2204

Answers (3)

geocar
geocar

Reputation: 9305

If your HTML looks like this:

<div class="category alternate">
   whatever<br>
</div>

then you want this:

$('div.category.alternate br').remove();

On the other hand, if your HTML looks like this:

<div class="category">
   <div class="alternate">
     whatever<br>
   </div>
</div>

then you want this:

$('div.category .alternate br').remove();

Upvotes: 6

Zefiryn
Zefiryn

Reputation: 2265

$('div.category alternate') tries to find all alternate tags inside div with class category. Maybe you ment $('div.category .alternate')

Upvotes: 2

Jezen Thomas
Jezen Thomas

Reputation: 13800

There is no such thing as an <alternate> tag.

Upvotes: 2

Related Questions