Kolodvor

ruby, rails, javascript, jquery, …

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • About me

Tag Archives: focus

Set focus on first field with Prototype

Posted on January 2, 2010 by vlado
1

If you are using jQuery see this post.

To set focus on first text field with Prototype I prefer something like this

  var firstField = $$('input:text:visible').first();
  if (firstField)
    firstField.focus();

but you can also try with Form.focusFirstElement or Form.findFirstElement

Posted in Prototype | Tagged focus, form, JavaScript, Prototype, selectors | 1 Reply

Set focus on first field with jQuery

Posted on January 17, 2008 by vlado
14

f you are using Prototype see this post.

Setting focus on the first text field with jQuery is as simple as

  $("input:text:first").focus();
  $("input:text:visible:first").focus();

Find more at http://docs.jquery.com/Selectors

Update: If you are on Rails you can use auto_focusable_forms, dependency free plugin that will focus first input for you.

Posted in jQuery | Tagged focus, form, jQuery, selectors | 14 Replies

Archives

  • March 2011
  • August 2010
  • July 2010
  • June 2010
  • February 2010
  • January 2010
  • September 2009
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • August 2007
  • July 2007

Meta

  • Log in
Proudly powered by WordPress