On This Page
Query - Content
Content methods in Query allow you to manipulate content accessing form data, text and html.
Value
Gets or sets the value of form elements.
Syntax
Get
Set
Name | Type | Description |
---|---|---|
newValue | any | The new value to set |
Alias
value
is also available as val
Returns
Get
Query object (for chaining).
Set
The value of the first element in the set.
Usage
Geting a Value
Setting a Value
Text
Gets or sets the text content of elements.
Syntax
Get
Set
Name | Type | Description |
---|---|---|
newText | string | The new text content to set |
Returns
Get
The combined text content of all elements in the set.
Set
Query object (for chaining).
Usage
Getting Text
Setting Text
HTML
Syntax
Get
Set
Name | Type | Description |
---|---|---|
newHtml | string | The new HTML content to set |
Returns
Get
The HTML content of the first element in the set.
Set
Query object (for chaining).
Usage
Getting HTML
Setting HTML
Outer HTML
Difference from HTML - Outerhtml returns the element including its own tag
Syntax
Get
Set
Name | Type | Description |
---|---|---|
newHtml | string | The new outer HTML content to set |
Returns
Get
- Single Element - The outer html of that element.
- Multiple Elements - An array of outer html , one for each matched element.
Set
Query object (for chaining).
Usage
Getting Outer HTML
Setting Outer HTML
Text Node
Versus text() -
text
will return text content recursively of nested nodes whiletextNode
will only return the text content of the selected node, in some cases this distinction can be essential.
Syntax
Get
Returns
Get
The combined text content of immediate text node children.