我的html是从外部来源引入的。问题是我希望使用br
定位双jQuery
,以便我可以完全删除第一个双br
并将所有其余的双br
转换为单br
。
html如下所示:
<div class="bottom-paragraph-drop">
<br>
<br>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<br>
<br>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</div>
jQuery的:
不知道该怎么做;
的内容 $('.bottom-paragraph-drop br').next('br').remove()
答案 0 :(得分:1)
给出以下HTML:
<input type="button" id="myBtn" value="Do It">
<div class="bottom-paragraph-drop">
<br />
<br /> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.is simply dummy
text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<br />
<br /> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</div>
您可以通过迭代div中的break标记并测试下一个元素是否为中断(然后删除元素)来消除第二个中断标记:
$('#myBtn').click(function() {
$('div br').each(function() {
if ($(this).next().is('br')) {
$(this).next().remove();
}
});
});
这是Fiddle Demo。
答案 1 :(得分:0)
你可以遍历所有的br元素并删除前两个,然后在索引中交替的brs -
val rdd = org.apache.spark.mllib.random.RandomRDDs.normalRDD(sc, 100, 10, 323L)
rdd.sortBy(identity).take(3)
// Array[Double] =
// Array(-2.678684754806642, -1.4394327869537575, -1.2573154896913827)
应该这样做。
答案 2 :(得分:0)
您可以使用RegularExpression定位这些br元素:
var div = document.querySelector('.bottom-paragraph-drop');
var text = div.innerHTML;
var result = text.replace(/^\s*<br>\s*<br>/, "").replace(/<br>\s*<br>/g, "<br>");
div.innerHTML = result;
<div class="bottom-paragraph-drop">
<br>
<br>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<br>
<br>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<br>
<br>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<br>
<br>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</div>
或者,如果你想定位'自闭'标签你的正则表达式看起来像这样:
/<br\s*\/*>\s*<br\s*\/*>/