Reputation: 3392
How can I use jQuery to find all the <br/>
tags within a div with class "post" and add an additional <br/>
tag after each?
Upvotes: 4
Views: 10605
Reputation: 34179
Just guessing here but I would try using the .after function like this
$('div.post br').after('<br/>');
Upvotes: 8
Reputation: 26607
Try something like this :
$('div.post br').each(function() {
$(this).after($(document.createElement('br')));
});
But as an advice, you should avoid using <br />
tags in <div>
elements. Formatting should be done by CSS, for example you can add a margin-after
to your div
to have the same result.
Upvotes: 0