How do I set the focus to the first input element in an HTML form independent from the id?
focus, forms, html, javascript
Solution
You can also try jQuery based method:
$(document).ready(function() {
$('form:first *:input[type!=hidden]:first').focus();
});
Problem
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.