clear

clear(element) -> HTMLElement

Clears the contents of a text input.

Example

This code sets up a text field in a way that it clears its contents the first time it receives focus:


$('some_field').onfocus = function() {
  // if already cleared, do nothing
  if (this._cleared) return

  // when this code is executed, "this" keyword will in fact be the field itself
  this.clear()
  this._cleared = true
}