Home > Web Front-end > JS Tutorial > body text

Detailed explanation of jQuery.contents() function

巴扎黑
Release: 2017-06-24 11:12:40
Original
2590 people have browsed it

The

contents() function is used to select all child nodes of the current matching element (including text nodes, comment nodes, etc.) and return it in the form of a jQuery object.

This function belongs to the jQuery object (instance).

Syntax

jQuery 1.2 Added this function.

jQueryObject.contents( )

Return value

contents()The return value of the function is jQuery type and returns A new jQuery object that contains all child nodes of the element matched by the current jQuery object (including all types of nodes such as elements, text, comments, etc.).

As long as there are any whitespace characters (spaces, newlines, etc.) between two HTML tags, they will be regarded as text nodes.

If the element is an