A similar question was asked before, but I'm looking for a jQuery solution using only the html below (ie. no classes or id attributes):
<h2>Foo</h2>
<p>asdf</p>
<ul><li>asdf</li></ul>
<p>asdf</p>
<h2>Bar</h2>
<p>asdf</p>
<p>asdf</p>
<h2>Baz</h2>
<p>asdf</p>
<p>asdf</p>
I'd like to use some jQuery like:
$('h2').afterButBeforeNext('h2').doSomething();
This should:
The prev selector should be able to do this: http://docs.jquery.com/Selectors/siblings#prevsiblings
$("h2 ~ *:not(h2)").doSomething();
You still need some sort of id or attribute to select just one single h2 element.
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