I have a div which has some text content( eg: My Name ) and the div is in RED background colour
If you are able to use latest CSS (which mean no stupid old browser), you may use CSS3's gradient function
$("#bar").mousemove(function (e) {
var now=e.offsetX/5;
$(this).css('backgroundImage', 'linear-gradient(to right, #00f 0%,#00f ' + now + '%,#f00 ' + now + '%,#f00 100%)');
}).click(function(e){
e.preventDefault();
var start=new Date().getTime(),
end=start+1000*10;
function callback(){
var now=new Date().getTime(),
i=((now-start) / (end-start))*100;
$("#bar").css('backgroundImage', 'linear-gradient(to right, #00f 0%,#00f ' + i + '%,#f00 ' + i + '%,#f00 100%)');
if(now
Example at: http://jsfiddle.net/hkdennis2k/ebaF8/2/