Insights on Ruby, Git, jQuery, Cappuccino, WordPress, Debian and OS X. Please subscribe if you find something useful!

jQuery – Set Mouse Focus On Page Load

Posted: May 9th, 2009 | Author: Jerod | Filed under: jQuery | Tags: | View Comments

First Input:

$(document).ready(function() {
  $('input:text:first').focus();
});

First Empty Input:

$(document).ready(function() {
  $('input:text[value=""]:first').focus();
});

View Comments on “jQuery – Set Mouse Focus On Page Load”

  1. 1 revivemarketing said at 8:02 am on July 23rd, 2010:

    Or to go one step further:
    First, Empty, Enabled Text Input

    $(document).ready(function() {
    $('input:text[value=""]:visible:enabled:first').focus();
    });

blog comments powered by Disqus