1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Ruby on Rails】ページ内ジャンプの実装

Posted at

目標

リンクをクリックすると、スクロールせずに同じページ内の指定した場所に飛ぶことができる

① idを指定する

飛ばしたい場所にidクラスを指定します。

app/views/dialogs/index.html.erb
<div id="category"></div>

②link_toを編集

<%= link_to "リンク名", リンク先のpath(anchor: "指定したid名") %>

下記が実際の例です

<%= link_to "カテゴリー", root_path(anchor: "category") %>

URLはこのようになります。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?