Setting Focus to 1st Text Field in jQuery

Sharing is Caring

Setting focus to the 1st field in jQuery is actually really simple: there are some plugins that also can do it automatically on each reload of a form.

I usually just use the following code on any pages where there is a form.


<script type="text/javascript">
$(document).ready(function() {
$("input:text:visible:first").focus();
});
</script>

Hope this helps.

Author: Brian Cline

Brian is a programmer living in Niagara Falls with ten years of development experience. He is passionate about automation, business process re-engineering, and gamification. For the last six years or so, he has been working with Salesforce and JavaScript.

Related Posts

Sharing is Caring