jQuery html() Method
jQuery html() Method
The html() method is used to set or return the content with tags of the selected elements.
For your Information:-
- When it is used to set content, it will overwrite the content of ALL matched elements.
- When it is used to return content, it returns the content of the FIRST matched element.
To return or set only the text content, we can use the text() method.
Syntax:-
Its syntax is:- $(selector).html(content) OR $(selector).html(function(index, currentcontent))
Further Explanation:-
Parameter | Description |
---|---|
content | Required. Specifies the new content for the selected elements. |
function(index,currentcontent) | Optional. Specifies a function that returns the new content for the selected elements
|