I have something like this: ...
<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>
anybody knows how to insert html after all the divs that have id like d+number
If the format doesn't have anything between those divs and #bla
like your example, here's a safer approach using .before()
(since div[id^=d]
would match <div id="doodlesticks">
as well).
$("#bla").before("<b>Hi There</b>");
Update: Since you said it's possible to give them a class, I'd do that, so give the content divs a class="content"
and use this jQuery:
$(".content:last").after("<b>Hi There</b>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With