开发者

How to give focus property to text box in Ruby on Rails?

开发者 https://www.devze.com 2023-01-07 15:53 出处:网络
I have a problem with setting the focus to the textbox for a login page in Ruby on Rails. I want to give focus to a user text field. Is there any way to give focus pr开发者_Go百科operty to text_field?

I have a problem with setting the focus to the textbox for a login page in Ruby on Rails. I want to give focus to a user text field. Is there any way to give focus pr开发者_Go百科operty to text_field?


In HTML5 you can do something like this:

<%= f.text_field :my_field, :autofocus => true %> 

The only way to achieve this without using HTML 5 is with JavaScript if I'm not mistaken. This has nothing to do with Rails, it's an HTML attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消