Home >Web Front-end >JS Tutorial >How to use jquery html() method
Usage of jquery html() method: 1. [html()] method sets or returns the content of the selected element; 2. When this method is used to return content, it returns the content of the first matching element. Content; 3. When this method is used to set content, the content of all matching elements is rewritten.
##Usage of jquery html() method:
Definition and usageSyntax
Return content:$(selector).html()Set content:
$(selector).html(content)Use function to set content:
$(selector).html(function(index,currentcontent))##Example
Change the content of all
elements:
$("button").click(function(){ $("p").html("Hello <b>world</b>!"); });Related free learning recommendations:
JavaScript
The above is the detailed content of How to use jquery html() method. For more information, please follow other related articles on the PHP Chinese website!