Replace contents/html of an html element

To replace existing contents/html of an html element using jquery we use html method. This method replaces existing contents/html of element with new html.

<input type="button" value="Change Html" onclick="ChangeHtml()" />
<div id="myDiv" class="myClass">
    This is a div
</div>

<script type="text/javascript">
    function ChangeHtml() {
        $("#myDiv").html("<h1>This is new html</h1>");
    }
   

</script>

Comments

Popular posts from this blog

Check if ViewBag is null or doesn't exist

Using Progress Bar In C#

Jquery serer side datatables in asp.net