tags:

views:

113

answers:

1

consider the following example

div > h1 > p > a

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

of course i use find('*') 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....

A: 

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')
karim79
the thing is , i need the h1 p a structure itself given the parent. i cannot control which parent is being selected.
gpo
@gpo - did you try the above?
karim79
yes. it works but like i mentioned, the hiearchy varies and i cannot control. what i need is to find() the descendant hiearchy of the given parent.
gpo