I’m trying to use jquery to select the first object in a list that follows a known object.
I have a document like this:
<div>A</div>
<div class="special">B</div>
<div>C</div>
<div>D</div>
<div>E</div>
I’ve run this previously:
foo = $(".special");
I want to run something like:
$( foo+" + div" );
To get back the div that contains “C”. This has got to be easy, but I can’t figure out how to do it.
(Note: I know about $( “.special + div” ). The problem is that I need to store “.special” as a variable.)
Try the
nextmethodDocumentation: http://api.jquery.com/next/
Fiddle Sample: http://jsfiddle.net/a5GWz/