Search code examples
htmlruby-on-railsactionview

How to call mouse events in text field


I want to get focus to the text field on mouseover. How to do this? Now my code lookd like this

  <div class='label_input'>
    <%= f.label :username %>
    <%= f.text_field :username %>
    <div class='clearfix'></div>
  </div>

Expecting similar to the HTML code

<input type="text" onmouseover="this.focus()"></input>

Solution

  • You could pass an onmouseover to text_field (docs).