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,

About author
Passionate about Web Technology and Web development. Loves Blogging. Keenly interested in Open Source Technology/Software/Framework.
3 total pingbacks on this post
  1. WordPress Rocker

Design Gala © 2012 All Rights Reserved

Developed by 76 Miles

Powered by WordPress