开发者

Non-trivial selections using jQuery based on content of previous element

开发者 https://www.devze.com 2022-12-12 10:06 出处:网络
Consider the following markup: <x> <y>code1</y> <z>stuff</z> 开发者_如何学运维<y>code2</y>

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"?


Like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消