jQuery > Attribute related method

.html() - Get set html content in jQuery

How to get or set the html content for a particular element using jQuery


To get or set the html content for a particular element, html() method can be used. 

alert($("#div2").html()); 

Above code snippet will alert the complete html content exist inside the element whose id is “div2” (in this case it's a div element). 

$("#div3").html("This is a good <b>boy</b>"); 

Above code snippet will set the specified html that is written under bracket to the element whose id is “div3”. 

 Views: 5308 | Post Order: 29



Write for us






Hosting Recommendations