开发者

jquery: get descendants of a parent with hiearchy intact

consider the following example

div > h1 > p > a

div.children() gives the immediate children which is h1

of course i use find('*')开发者_如何学Go to get all descendants.

however, i need div.find( h1 > p > a) not div.find(h1,p,a), which is what the default find('*') is doing: it is simply ignoring the original hiearchy.

please note that div can be anything. the whole hiearchy can vary in depth. ie) div > h1 > span > b > i > a and etc....


I'm not entirely sure what you mean, but have you tried ancestor descendant instead of parent > child (you mention that your hierarchy can be of any depth, parent > child will only look for immediate children):

div.find('h1 p a')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜