How can I link to a div on the current page.
For example, I have
<%= link_to "Comments", :anchor => "comments_div" %>
which links to www.url.com/#comments_div
.
How can I link to a div from the current page, including params in the url, eg: www.url.com/r?utf8=✓&page_id=1232&lod_in=f#comments_div
This should do it:
<%= link_to "Comments", "#{request.original_url}#comments_div" %>
Reference: request.original_url
You can link to the div on the current page like so:
<%= link_to "Comments", "#comments_div" %>
No need to submit a new request.
you can simply do an a tag with the div name of the div you want to jump to
<a href="#Comments">Comments</a>"
Then you'd have your div down bellow:
<h1 id="Comments">Comments</h1>
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.