javascript - How to select first element in each group using jQuery? -


given following html input:

<p>a</p> <p>b</p> <p>c</p> <div>d</div> <p>e</p> <p>f</p> <p>g</p> 

i can use following select b, c, f , g:

$('p + p') 

how can select a , e?

$('???').each(function() {     var restofgroup = $(this).next('p'); }); 

you can use inverse:

$('p:not(p+p)') 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -