In the following way, you can change the color over a period of time. At first it will turn yellow in a few seconds until it turns green.
$(function(){ $("#two").focus(); setTimeout(function() { $('#two').css("background-color", "green"); }, 2000); });
body{color:white;} #fis{height:600px;width: 60px;background-color:red;} #two{height:600px;width: 60px;background-color:yellow; transition:background-color 1s ease;} #thr{height:600px;width: 60px;background-color:blue;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="fis">hello </div> <div id='two' tabindex='1'>mr </div> <div id='thr'>john </div>
ketan source share