In this post, we are going to see jQuery html method.
html method is used to get html content of first matched elements, other elements will be ignored and html(‘new html content’) is used to set html content for all matched elements.
Syntax for html() :
$("selectors").html()
Example :
$("div").html();
Syntax for html(‘new html content’) :
$("selectors").html('new html content')
Example:
$("div").html('this text is being set by html method');
Let’s understand with the help of example:
Jquery html method example Jquery html method example
Hello world from java2blog!!!!
Welcome to JQuery.
Live demo:Jquery html method example on jsbin.com