Focus on the first input element in jQuery

Just in case you want to focus on the first element in a form, here is how to do it through one simple jQuery sector:

$('#form-id :input:enabled:visible:first').focus();

Once you select the right form (#form-id), it’s time to specify any input elements including text areas (:input) which are editable (:enabled), visible (:visible), and first in the form (:first).

Viliam is a co-founder and in a position that could be called CTO.

Posted in Web

Leave a Reply