Here I created a working demo of what you want http://jsfiddle.net/kPbfL/1/
You need to add the tabindex attribute to the div :
Markup:
<div id="mydiv" tabindex="-1"></div>
Javascript
$("#mydiv").focusin(function() { $("#mydiv").css("background","red"); }); $("#mydiv").focusout(function() { $("#mydiv").css("background","white"); });
CSS
#mydiv{ width : 50px; height:50px; border : 1px solid red; }
Mohammad adil
source share