class method Form.Element.activate

View source on GitHub →

Form.Element.activate(element) → Element

Gives focus to a form control and selects its contents if it is a text input.

This method is just a shortcut for focusing and selecting; therefore, these are equivalent (aside from the fact that the former one will not return the field) :

Form.Element.focus('myelement').select()
$('myelement').activate()

Guess which call is the nicest? ;)

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.