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 -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -