html - Target last div in the group -
i need target each last <div> before each <h3>. there programatic way can done in css?
for other reasons, can not / don't want target <h3> instead.
<div id="main"> <h3>title</h3> <div class="post">…</div> <div class="post"><!-- target div--></div> <h3>title</h3> <div class="post">…</div> <div class="post">…</div> <div class="post">…</div> <div class="post"><!-- target div--></div> <h3>title</h3> <div class="post">…</div> <div class="post">…</div> <div class="post"><!-- target div--></div> </div>
actually isn't possible.
if able wrap blocks parent tags can each last child css selectors #main .post:last-child:
<div id="main"> <div> <!-- wrap "h3" works --> <h3>title</h3> <div class="post">…</div> <div class="post"><!-- target div--></div> </div> <h3>title</h3> <div> <!-- wrap without "h3" works --> <div class="post">…</div> <div class="post">…</div> <div class="post"><!-- target div--></div> </div> </div> note: :last-child selector not supported in ie8 , earlier versions.
what mean with: "for other reasons, can not / don't want target instead."?
jquery workaround work want with original markup:
var $main = jquery('#main'); $main.find('h3').prev().add( $main.find(':last') ) //.text('<!-- target div-->');
Comments
Post a Comment