1//test if element has focus in jQuery
2if ($("#myElementID").is(":focus")) {
3 //I have the focus
4}
5
6//test if element has focus in plain Javascript
7var myElement = document.getElementById('myID');
8if(myElement === document.activeElement){
9 //myElement Has Focus
10}
11
1var myElement = document.getElementById('myID');
2if(myElement === document.activeElement){
3 //myElement Has Focus
4}
5