Reputation: 2418
My structure is like this:
<p>something</p>
<br/>
<br/>
<p>ssddfgdfg</p>
<br/>
<br/>
<p>dsdfsfsdfsdfsd</p>
<br/>
<br/>
I want to remove one br tag
whenever 2 br tag
comes together, like this:
<p>something</p>
<br/>
<p>ssddfgdfg</p>
<br/>
<p>dsdfsfsdfsdfsd</p>
<br/>
How can I achieve this using jQuery?
Upvotes: 2
Views: 4658
Reputation: 1113
I am using this code
$('br').each(function ()
{
if ($(this).next().is('br'))
{
$(this).next().remove();
}
}
Upvotes: 0
Reputation: 4829
You can try doing
$('br').next('br').remove();
This will remove the second <br/>
. There might be a better solution though.
EDIT: As I said other answers were better :)
Upvotes: 3