Basic jQuery Tutorial: Write or Append content to DIV

In this article, I will be showing you how to write or append content to DIV. When you write, all the text present before will be replaced by new content. When you append, new content will be added after the previous content already present there.


VIEW DEMO

Here is my html code. This contains a div with class ‘content’ and two buttons (Write and Append).

<div class="content">
	Write Something!
</div>	
<br />	
 
<button>Write</button>
<button>Append</button>

Here is the jQuery code to write data:

$("#write").click(function(){			
	$(".content").html("Hello World! ");				
});

Here is the jQuery code to append data:

$("#append").click(function(){			
	$(".content").append("Hello World! ");				
});


VIEW DEMO

Cheers,