Reputation: 8070
Good Day.
Actually it is the wordpress site but i need the general solution using jquery(if feasible)
I trying to remove the
tag next to end of the div.
See I am using the div as like here
<div class="one_third">
<p>This is for testing</p>
</div>
<br> <!--This one -->
<div class="one_third">
</div>
<br><!--This one -->
<div class="one_third">
</div>
<br><!--This one -->
In the above example i am using the class of one_third in a div inside this div i am using br tag too. But all i am want to remove the br tag which is in outside the div i mean in the end of the div in jquery.
</div>
<br>
I am not sure how to do this in jquery (Actually i try with wordpress disable wpautop is removing the br tag which is inside the div too (I don't want to remove the br tag inside the div only outside the div i mean end of the div )).
Any suggestion would be great :)
Thanks, vicky
Upvotes: 0
Views: 2231
Reputation: 115242
You can use next()
and remove()
methods in jQuery for that
$(".one_third").next('br').remove();
Upvotes: 3
Reputation: 207527
A non JavaScript solution would be a simple CSS sibling selector
.one_third + br {
display : none;
}
If you really want to use jQuery, you can use the same selector and use remove()
$(".one_third + br").remove();
Upvotes: 3
Reputation: 318302
You should just place the HTML on one line.
wpautop inserts <br>
on newlines, so placing the HTML code on one line avoids the entire issue.
<div class="one_third"><p>This is for testing</p></div><div class="one_third"></div><div class="one_third"></div>
The way you structure the markup is everything when wpautop is enabled.
Upvotes: 7
Reputation: 388416
It is the next sibling of the element with class one_third
$('.one_third').next('br').remove()
Demo: Fiddle
Upvotes: 6