Change div text using jquery

Many times in web development we need to <strong>change div text using jquery</strong>, so this is a simple tutorial for this.

by Nikhil Mangal

HTML

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<a href="#" id="changeText">Click here to change text of div</a>
<div id="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>

CSS

#content
{
padding:10px;
background:#eee;
width:300px;
}

JavaScript

$(document).ready(function(){
		$('#changeText').click(function(){
			$('#content').text("This is text changed using jquery");
		});
	});