Rafael Santos wrote:
> hey guys, could u help me?
>
> this is my lines:
> $("#month").keypress( function(){
> len = $(this).val().length;
> if(len == 1){ document.getElementById("day").focus(); }
> });
>
> this firebug give me an error.
>
> if(len == 1){ $("#day").focus(); }
>
> this do nothing...
>
> what am i doing wrong
Please consult the website for more information, but in short you are
doing 2 things wrong. First of all, you are using
"document.getElementById which can be shortened to $('#..') or
jQuery('#..') and secondly you have to make sure that the element is
focusable (e.g. not hidden, disabled or otherwise unfocusable).
Try this:
jQuery("#month").keypress(function() {
if (this.length == 1)
jQuery('#day')[0].focus();
});
[or]
$("#month").keypress(function() {
if (this.length == 1)
$('#day')[0].focus();
});
-- Gilles
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/