class method

View source on GitHub → → Element

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


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

  $('searchbox').onfocus = function() {
     // You can also rely on the native method, but this will NOT return the element!
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.