jQuery basics

Element focus

  • Elements get focus
// Get the focused element:
var $focused = $(':focus');

// No jQuery:
var focused = document.activeElement;

// Does the element have focus:
var hasFocus = $('foo').is(':focus');

// No jQuery:
elem === elem.ownerDocument.activeElement;
  • That the element receives the focus / blur focus
focus()
blur()

Guess you like

Origin www.cnblogs.com/develon/p/11711272.html