Easy Tutorial
❮ Jq Sel Id Html Appendto ❯

jQuery contents() Method

jQuery Traversal Methods

Example

Find all text nodes within a <div> element and wrap them with a <b> element:


Definition and Usage

The contents() method returns all direct children, including text and comment nodes of the selected element.

Text nodes are the actual text displayed by the element.

This method is similar to the children() method, except that it returns text and comment nodes. The contents() method can also access the HTML of an iframe if it is in the same domain.


Syntax


jQuery Traversal Methods

❮ Jq Sel Id Html Appendto ❯