如何使用jQuery删除前两个BR标签? [英] How to remove the first two BR tags with jquery?
本文介绍了如何使用jQuery删除前两个BR标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想使用jquery删除前两个BR标签.
<div id="system">
<BR CLEAR="ALL"><BR>// I want to remove both BR.
...
<BR>...
...
<BR>
我认为是这样的.但是我不确定.
$('#system br').remove();
有人可以告诉我该怎么做吗?
解决方案
使用 :lt()
:
$('#system br:lt(2)').remove();
:lt()
将基于零的整数作为其参数,因此2表示第三个元素.因此:lt(2)
是选择元素小于"第3个.
示例: http://jsfiddle.net/3PJ5D/ >
I'd like to remove only the first two BR tags with jquery.
<div id="system">
<BR CLEAR="ALL"><BR>// I want to remove both BR.
...
<BR>...
...
<BR>
I assume something like this. But I am not sure.
$('#system br').remove();
Could anyone tell me how to do this please?
解决方案
Use :lt()
:
$('#system br:lt(2)').remove();
:lt()
takes a zero-based integer as its parameter, so 2 refers to the 3rd element. So :lt(2)
is select elements "less than" the 3rd.
Example: http://jsfiddle.net/3PJ5D/
这篇关于如何使用jQuery删除前两个BR标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文