Is there a 'has focus' in JavaScript (or jQuery)?

后端 未结 10 1273
北恋
北恋 2020-11-30 00:36

Is there something I can do like this (perhap via a plugin)

if ( ! $(\'form#contact input]\').hasFocus()) {
  $(\'form#contact input:first]\').focus();
}
         


        
10条回答
  •  没有蜡笔的小新
    2020-11-30 00:52

    There is a plugin http://plugins.jquery.com/project/focused

    Also you can check Using jQuery to test if an input has focus

提交回复
热议问题