0

Using jQuery to test if an input has focus

jQuery 1.6+

$("..").is(":focus")

jQuery 1.5 and below

jQuery.expr[':'].focus = function(elem) {
  return elem === document.activeElement && (elem.type || elem.href);
};
add comment
Suggest a different solution or add another example