class method Form.Element.select

View source on GitHub →

Form.Element.select(element) → Element

Selects the current text in a text input. Returns the element.

Example

Some search boxes are set up so that they auto-select their content when they receive focus.

  $('searchbox').onfocus = function() {
    Form.Element.select(this)
     // You can also rely on the native method, but this will NOT return the element!
    this.select()
  }
Focusing + selecting: use Form.Element.activate!

The Form.Element.activate method is a nifty way to both focus a form field and select its current text, all in one portable JavaScript call.