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();
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();
Share
Improve this question
edited Sep 30, 2012 at 18:05
Felix Kling
818k181 gold badges1.1k silver badges1.2k bronze badges
asked Sep 30, 2012 at 17:50
user1685565user1685565
3372 gold badges5 silver badges16 bronze badges
2
- That should work, your selector is wrong. What's the HTML look like? – sachleen Commented Sep 30, 2012 at 17:52
- 1 What do you think he means? You have some HTML being sent to the browser, and you want to modify the elements, right? Well, "What does the HTML look like?" – I Hate Lazy Commented Sep 30, 2012 at 18:06
3 Answers
Reset to default 6If 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();
There is no such thing as an <alternate>
tag.
$('div.category alternate')
tries to find all alternate
tags inside div
with class category
. Maybe you ment $('div.category .alternate')