Products and Tools

Focus on the first input element in jQuery

|Last updated on Oct 25, 2017|1 min read
LinkedInFacebookX
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).

Related blog posts