How do I set the focus to the first input element in an HTML form independent from the id?

Is there a simple way to set the focus (input cursor) of a web page on the first input element (textbox, dropdownlist, …) on loading the page without having to know the id of the element?

I would like to implement it as a common script for all my pages/forms of my web application.

61 thoughts on “How do I set the focus to the first input element in an HTML form independent from the id?”

Leave a Comment