Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if a field has focus?

Very similar to How do I find out which DOM element has the focus? except that I'm not trying find the field that has focus, I just need to know if a particular one already has focus. Is that possible?

like image 636
mpen Avatar asked Mar 01 '11 01:03

mpen


1 Answers

You can try

$("input#id").is(":focus")

Edit: You should read this post if you plan to use it on older browsers. http://forum.jquery.com/topic/is-the-focus-selector-valid

like image 78
Amir Raminfar Avatar answered Nov 03 '22 23:11

Amir Raminfar