我有这样的事情:......
<div id="d120" >content</div>
<div id="d123" >content</div>
<div id="d112" >content</div>
<div id="d145" >content</div>
<div id="d134" >content</div>
//Insert here hello world
<div id="bla" >asd</div>
<div id="footer" >asd</div>
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何在所有id为d + number的div之后插入html
如果格式在这些 div 之间没有任何内容并且#bla像您的示例一样,则使用以下更安全的方法.before()(因为也div[id^=d]可以匹配)。<div id="doodlesticks">
$("#bla").before("<b>Hi There</b>");
Run Code Online (Sandbox Code Playgroud)
更新:既然你说可以给他们一个类,我会这样做,所以给内容 divclass="content"并使用这个 jQuery:
$(".content:last").after("<b>Hi There</b>");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5896 次 |
| 最近记录: |