top of page

Definition and Usage

The html() method sets or returns the content (innerHTML) of the selected elements.

When this method is used to return content, it returns the content of the FIRST matched element.

When this method is used to set content, it overwrites the content of ALL matched elements.

 

Tip: To set or return only the text content of the selected elements, use the text() method.

 

Syntax

Return content:

 

$(selector).html()

Set content:

 

$(selector).html(content)

Set content using a function:

 

$(selector).html(function(index,currentcontent))

 

    Parameter                                                               Description                        

    content                                                   Required. Specifies the new
                                                                  content for the selected                                                                    elements (can contain HTML tags)

function(index,currentcontent)                  Optional. Specifies a function

                                                                  that returns the new 

Jquery HMTL

Are the Keywords

bottom of page