How to get HTML of any control using jQuery

In this post, we will see that how we can get the HTML part or I should say innerHTML of any control. Well,
jQuery provides a function "html()" which will give the html of the control. For example, I have placed a div control on the page which has h1 and h2 tag.
<div id="dvExample">
    <h1>
        jQuery By Example Rocks..
    </h1>
    <h2>
       It has really cool tips.
    </h2>
</div>
Below jQuery code will display an alert with div's html.
$(document).ready(function()
{
  alert($("#dvExample").html());        
});
Output:

SHARE

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..