0

I creating a script, and I like to know if a scecific field is focused by using the following code:

console.log($('#element_title').is(':focus'));

The problem is that either the field is focus or not, I always get "false" as result. Am I doing something wrong with that ?

The element I try to check is a text field.


The problem solved, with the reccomendation of the "adeneo".

Thanks a lot :)

Tim Post
  • 32,782
  • 15
  • 106
  • 168
KodeFor.Me
  • 12,429
  • 26
  • 92
  • 160

1 Answers1

1

I believe this is what you want:

$('#element_title').focus(function()
{
console.log('I have the focus now!');
});
svenbravo7
  • 317
  • 1
  • 6