Jquery: add html after group divs
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>
does anyone know how to insert html after all divs having id as d + number
+5
5 answers
If the format has nothing between these divs and #bla, as your example, here is a safer approach using .before()(since it div[id^=d]will match <div id="doodlesticks">).
$("#bla").before("<b>Hi There</b>");
Update: . Since you said you could give them a class, I would do it, so give a div div and use this jQuery:
$(".content:last").after("<b>Hi There</b>");
+3