html() in jQuery
Using this method it can get the HTML contents of the first element in the set of every matched element.
Browser's innerHTML property is used by this method.
- htmlString - A string of HTML to set as the content of each matched element.
- index - Index position of the element in the set.
- currentHtmlString - The old HTML value.
Example 1 - get html string
Example 2 - set html string
Example 3 - get old html string and set new html string
Example 4 - Execution steps
Difference between html() and text()
Using text() method it retrieves only the text from an element, but using html() method both the text as well as the HTML markup can be retrieved from the element.