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
  • 33,371
  • 15
  • 110
  • 174
KodeFor.Me
  • 13,069
  • 27
  • 98
  • 166

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