i have html being pulled in external source. problem want target double br
jquery
, can remove first double br
entirely , convert of rest of double br
single br
.
the html looks following:
<div class="bottom-paragraph-drop"> <br> <br> dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book.is dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book.is dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. <br> <br> dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. </div>
jquery:
not sure do; along lines of
$('.bottom-paragraph-drop br').next('br').remove()
given following html:
<input type="button" id="mybtn" value="do it"> <div class="bottom-paragraph-drop"> <br /> <br /> dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book.is dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book.is dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. <br /> <br /> dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. </div>
you can eliminate second break tag iterating on break tags in div , testing if next element break (and remove element):
$('#mybtn').click(function() { $('div br').each(function() { if ($(this).next().is('br')) { $(this).next().remove(); } }); });
here fiddle demo.
Comments
Post a Comment