My current code is:
= link_to 'Compare Schools', '#', class: 'btn-default'
I want to essentially link back to the top of the page. To do so in regular html I would link to a div at the top of the page (in this case div="header-wrapper"), which would make the code:
= link_to 'Compare Schools', '.section-wrapper', class: 'btn-default'
This however gives me an error message No route matches [GET] "/.section-wrapper" when I click on the button.
Remember that links need to be to separate pages, or within the page. If prefixed with the anchor indicator #
it's presumed to be an anchor destination. Those are typically made like this:
%a{ name: 'anchor_name' }
Then you can link to this:
= link_to('Link', '#anchor_name')
If you try and link to a CSS selector, it's going to be interpreted as a relative URL and it won't work.
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.