This question already has an answer here:
- jQuery select descendants, including the parent 8 answers
I have a div with further divs contained in it.These divs internally contain table/div in them. How can I select this parent div and its children in jquery? Parent div has the class "
I have tried following
but it is only selecting parent div and its children.Its not going deep to the root.I am using jquery 1.9.0
You can use the
, separator in order to select multiple queries. Something like this should do.
var klo=$(".AccordionTitle.AccordionTitle-selected, .AccordionTitle.AccordionTitle-selected > *")
This will select the element itself as well as elements right beneath the element itself in the DOM tree.
If you're looking for a solution to find child elements and their child elements too, something like this will do.
var klo=$(".AccordionTitle.AccordionTitle-selected, .AccordionTitle.AccordionTitle-selected *")
The principle is the same, only now you've omitted the
> operator which will only allow children right below the original node.