Using jQuery to test if an input has focus

后端 未结 15 1427
梦谈多话
梦谈多话 2020-11-22 05:42

On the front page of a site I am building, several

s use the CSS :hover pseudo-class to add a border when the mouse is over them. One of
15条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 06:13

    There is a plugin to check if an element is focused: http://plugins.jquery.com/project/focused

    $('input').each(function(){
       if ($(this) == $.focused()) {
          $(this).addClass('focused');
       }
    })
    

提交回复
热议问题