Autofocus for an Input Element

I have an input element on the page, and I would like for the cursor to automatically be in the input element when the pages loads. I believe that I need to use the autofocus attribute. Is this correct? Here are some examples of what I have tried:

input.attribute("autofocus");
input.attribute("autofocus", true);
input.attribute("autofocus", "true");

I would appreciate any suggestions you may have. Thanks in advance.

Answers

Sign In or Register to comment.