jQuery html() method example

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

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.