jQuery contents() method
Example
Find
all text nodes inside the element, and wrap them with wrap them with the element:
$("div").contents().filter("em").wrap("");
Try it »
Definition and Usage
The contents() method returns all direct child elements, including text and comment nodes of the selected element.
A text node is the actual text displayed by an element.
This method is similar to the children() is similar to the method, except that it returns text and comment nodes. If in the same domain, the contents() method can also access the HTML of an iframe.
Syntax
$(
selector
).contents()
jQuery Traversal Methods