To select an element by ID in jQuery, you can use the CSS-like syntax
#id.

jQuery("#key1).focus();


Your jQuery("input.key1").focus(); statement told jQuery to look for
an input with the class property of "key1".

On Jul 18, 3:54 am, annet <[email protected]> wrote:
> In web2py_ajax.html I have the following line of code to set focus on
> the first visible field in forms:
>
> jQuery("input:text:not(.date):first:visible").focus();
>
> In a view with three forms, named form1, form2, form3, the focus is
> set on the first field of form2 whereas I want the focus to be set on
> the first field of form1. I tried:
>
> jQuery("input:text:not(.date):first:visible").focus();
> jQuery("input.key1").focus();
>
> ... but that doesn't work. How do I set focus on the field with id
> key1?
>
> Kind regards,
>
> Annet.

Reply via email to