Ruby on Rails 5.0.0.1にて開発しています。
とても初歩的で低レベルのことと理解しながら、自分で調べていてもうまくいかず、アドバイス頂けますと幸甚です。
よくある「Top」を押すとTopに戻るボタンを作成しています。
以下の通りファイルを構成し、CoffeeScript
を書いていますが、クリックしても一切反応せず、初歩的なことなのだと思いますが、何がいけないのかご指摘頂けますと助かります。
html
1<div id="page-top" class="page-top"> 2 <p> 3 <a id="move-page-top" class="move-page-top"> 4 <i class="fa fa-arrow-up fa-2x" aria-hidden="true" style="color:white"></i> 5 TOP 6 </a> 7 </p> 8 </div>
css
1.page-top{ 2 margin: 0 ; 3 padding: 0 ; 4} 5.page-top p{ 6 margin: 0 ; 7 padding: 0 ; 8 position: fixed ; 9 right: 20px ; 10 bottom: 20px ; 11 color: white; 12} 13.move-page-top{ 14 display: block ; 15 background: $gray ; 16 width: 50px ; 17 height: 50px ; 18 line-height: 10px ; 19 text-decoration: none ; 20 text-align: center; 21 -webkit-transition:all 0.3s ; 22 -moz-transition:all 0.3s ; 23 transition:all 0.3s ; 24} 25.move-page-top:hover{ 26 opacity: 0.85 ; 27}
CoffeeScript
1#ファイル名: top.js.coffee 2 3$('#move-page-top').click -> 4 $('html,body').animate scrollTop:0,'slow'
念のため、その他読込のためのコードは以下の通り
html
1<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
application.js
//= require jquery //= require jquery_ujs //= require turbolinks //= require tether //= require bootstrap-sprockets //= require_tree .
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。