Tuesday, 16 March 2010

focus on an input field using jQuery

To focus on a login input box with id 'login' on page startup, try:

$("#login").focus();

To following script can be used to trigger some action on focus of each input field in the form.

$("input").focus(function () {
$(this).next("span").css('display','inline').fadeOut(1000);
});

1 comment:

  1. Use the following script to focus on first input field in the form.
    $("input[type='text']:enabled:first").focus();

    ReplyDelete