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
Post a Comment