JQuery DOM tree

The following is an example of retrieving the "value" of the second image:

HTML markup:


<div>
  <ul>
    <li><a href="joy.html"><img src="image1.jpg"/></a></li>
    <li><a href="owl.html"><img src="image2.jpg"/></a></li>
  </ul>
</div>

jQuery:


var nextImage=$('img[src"bar.jpg"]') //define the starting point
                         .closest('li') //travel up to the closest list item
                         .next( ) //move to the next list item
                         .find('img') //find the image tag in that line
                         .attr('src'); //grab the source attribute found in the image tag

So now variable nextImage contains image2.jpg.
Note that // are comments that will not be seen by the user.