In my case I'm using the .contents() instead of the .children() because the .contents() supports text nodes, which is not the case of .children() . I have this code:
<body>
blablabla
<p>example</p>
<div>
<a>link</a>
</div>
</body>
var body_content = $("body").contents();
The body_content
variable would return 3 nodes: a text node, a paragraph node and a div node, while I expect it to return the anchor node that is located in the div. I looked for an alternative in the jQuery documentation and I didn't find any function that does what I want. Are there ways to do it "manually" ?