<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
$('p').wrapInner('<span></span>');
$('p').html($('p').text().split(' ').join('</span> <span>'));
$('span').click(function() {
$('span').removeClass('color');
$(this).addClass('color');
});
});
</script>
<style type="text/css">
.color
{
background-color:Red;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>This is a sample application</p>
</div>
</form>
</body>
</html>
This will solve your problem...