Alex Rivera | Logout

How do I make a field autofocus?

Asked 2011-01-13T02:48:14.553
9

I need this field to be focused when the user opens the page. I don't know if it changes anything but it's inside a modal window I load from a PHP file.

Is there an easy way to do it?

Edit
Report

1 Answer

18

Using JavaScript, you can achieve this:

document.onload = function() {  
  document.getElementById("question-box-0").focus();
}
answered 2011-01-13T02:49:40.213

Your Answer