tags:

views:

24

answers:

1

Consider the following markup:

<x>
   <y>code1</y>
   <z>stuff</z>
   <y>code2</y>
   <z>foobar</z>
</x>

Using jQuery, how do I select the <z>foobar</z> node in the given markup using the following rule: find the z-node that follows after a y-node which has a body containing "code2"?

+2  A: 

Like this:

$('y:contains("code2") + z')
SLaks