teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コードブロックで囲んでいなかったコードを削除しました。

2017/07/16 10:09

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -18,25 +18,6 @@
18
18
 
19
19
  ###該当のソースコード
20
20
 
21
- jQuery(function($) {'use strict',
22
-
23
- // all Parallax Section
24
- $(window).load(function(){'use strict',
25
- $("#services").parallax("50%", 0.3);
26
- $("#parador").parallax("50%", 0.3);
27
- });
28
-
29
-
30
- // Navigation Scroll
31
- $(window).scroll(function(event) {
32
- Scroll();
33
- });
34
-
35
- $('.navbar-collapse ul li a').click(function() {
36
- $('html, body').animate({scrollTop: $(this.hash).offset().top - 79}, 1000);
37
- return false;
38
- });
39
-
40
21
  ```ここに言語を入力
41
22
  $(function() {
42
23
  var pageTop = $('.page-top');

1

コードブロックで囲みました。

2017/07/16 10:09

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  Consoleを見ると以下のエラーメッセージが表示されました。
7
7
 
8
+ ```ここに言語を入力
8
9
  Uncaught TypeError: Cannot read property 'top' of undefined
9
10
  at HTMLAnchorElement.<anonymous> (main.js:61)
10
11
  at Function.each (jquery.js:4)
@@ -13,9 +14,64 @@
13
14
  at main.js:12
14
15
  at dispatch (jquery.js:5)
15
16
  at v.handle (jquery.js:5)
17
+ ```
16
18
 
17
19
  ###該当のソースコード
18
20
 
21
+ jQuery(function($) {'use strict',
22
+
23
+ // all Parallax Section
24
+ $(window).load(function(){'use strict',
25
+ $("#services").parallax("50%", 0.3);
26
+ $("#parador").parallax("50%", 0.3);
27
+ });
28
+
29
+
30
+ // Navigation Scroll
31
+ $(window).scroll(function(event) {
32
+ Scroll();
33
+ });
34
+
35
+ $('.navbar-collapse ul li a').click(function() {
36
+ $('html, body').animate({scrollTop: $(this.hash).offset().top - 79}, 1000);
37
+ return false;
38
+ });
39
+
40
+ ```ここに言語を入力
41
+ $(function() {
42
+ var pageTop = $('.page-top');
43
+ pageTop.hide();
44
+ $(window).scroll(function () {
45
+ if ($(this).scrollTop() > 600) {
46
+ pageTop.fadeIn();
47
+ } else {
48
+ pageTop.fadeOut();
49
+ }
50
+ });
51
+ pageTop.click(function () {
52
+ $('body, html').animate({scrollTop:0}, 500, 'swing');
53
+ return false;
54
+ });
55
+ });
56
+
57
+ });
58
+ // Preloder script
59
+ jQuery(window).load(function(){'use strict';
60
+ $(".preloader").delay(1600).fadeOut("slow").remove();
61
+ });
62
+ //Preloder script
63
+ jQuery(window).load(function(){'use strict';
64
+
65
+ // Slider Height
66
+ var slideHeight = $(window).height();
67
+ $('#home .carousel-inner .item, #home .video-container').css('height',slideHeight);
68
+
69
+ $(window).resize(function(){'use strict',
70
+ $('#home .carousel-inner .item, #home .video-container').css('height',slideHeight);
71
+ });
72
+ });
73
+
74
+ // User define function
19
75
  function Scroll() {
20
76
  var contentTop = [];
21
77
  var contentBottom = [];
@@ -34,8 +90,67 @@
34
90
  }
35
91
  })
36
92
  };
93
+ ```
37
94
 
95
+ 《CSS》
38
96
 
97
+ ```ここに言語を入力
98
+ .page-top {
99
+ position: fixed;
100
+ bottom: 20px;
101
+ right: 20px;
102
+ font-size: 77%;
103
+ }
104
+ .page-top a {
105
+ background: #666;
106
+ text-decoration: none;
107
+ color: #fff;
108
+ width: 100px;
109
+ padding: 30px 0;
110
+ text-align: center;
111
+ display: block;
112
+ border-radius: 5px;
113
+ }
114
+ .page-top a:hover {
115
+ text-decoration: none;
116
+ background: #999;
117
+ }
118
+ ```
119
+
120
+ 《HTML》
121
+
122
+ ```ここに言語を入力
123
+ <body id="top">
124
+ <div class="preloader">
125
+ <div class="preloder-wrap">
126
+ <div class="preloder-inner">
127
+ <div class="ball"></div>
128
+ <div class="ball"></div>
129
+ <div class="ball"></div>
130
+ <div class="ball"></div>
131
+ <div class="ball"></div>
132
+ <div class="ball"></div>
133
+ <div class="ball"></div>
134
+ </div>
135
+ </div>
136
+ </div><!--/.preloader-->
137
+ <header id="navigation">
138
+ <div class="navbar navbar-inverse navbar-fixed-top" role="banner">
139
+ <div class="container">
140
+ <div class="navbar-header">
141
+
142
+
143
+ ---------- 中略 ----------
144
+
145
+
146
+ </footer> <!--/#footer-->
147
+ <a href="#home" class="page-top"><i class="fa fa-chevron-up" aria-hidden="true"></i><br>PAGE TOP</a>
148
+
149
+
150
+ </body>
151
+ </html>
152
+ ```
153
+
39
154
  同様の問題を紹介されているサイトで「offset().top);
40
155
  」に問題があるということは理解できました。
41
156
  ただ、どのように修正すれば、下層ページでもボタンが表示されるようになるのか分かりません。