简体   繁体   中英

specifying additional attributes on anchor tag using link_to in rails

Let us say I want an output html like this in rails:

<a role="menuitem" tabindex="-1" href="#">Action</a></li>

How can I specify the attribues (role and tabIndex) using link_to helper in rails.

Check out the Rails docs for link_to

link_to 'Action', '#', role: 'menuitem', tabindex: -1

should do the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM