goto.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. $("*").each(function (index, element) {
  2. // 此元素被點選後執行
  3. $(this).click(function (e) {
  4. // 取得被點選元素的屬性:data-gt-target
  5. var target = $(this).attr("data-gt-target");
  6. var duration = $(this).attr("data-gt-duration");
  7. var offset = $(this).attr("data-gt-offset");
  8. // JS 語法:判斷式
  9. // if (條件) {程式區塊}
  10. // 當條件成立,會執行程式區塊
  11. // 如果 目標有資料 才會執行 { } 內的程式
  12. // 避免出現 undefine (未定義 - 不存在的資料)
  13. if (target) {
  14. //console.log("目標:" + target);
  15. //console.log("時間:" + duration);
  16. //console.log("位移:" + offset);
  17. // 上方位置 = 目標區塊.位移().上方位置
  18. var top = $(target).offset().top;
  19. //console.log("要前往元素的上方位置:" + top);
  20. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  21. // parseInt() 將文字轉為數字
  22. $("html").stop().animate({
  23. scrollTop: top - offset
  24. }, parseInt(duration));
  25. }
  26. });
  27. });
  28. // 避免動畫與使用者滾輪衝突
  29. // html 在滾動滾輪時 停止 html 所有效果
  30. $("html").on("mousewheel", function () {
  31. $("html").stop();
  32. });
  33. // gotop下滑效果
  34. $(".arrow").hide();
  35. $(window).scroll(function () {
  36. var y = window.scrollY;
  37. if (y > 500) {
  38. $(".arrow").show();
  39. } else {
  40. $(".arrow").hide();
  41. }
  42. });
  43. console.log(28);
  44. // $('.nav-item2').click(function(){
  45. // $(this).toggleClass('after-nav')
  46. // })
  47. $(document).ready(function () {
  48. $.ajax({
  49. method: "GET",
  50. url: "homepageimg.json",
  51. dataType: "json",
  52. })
  53. .done(function (msg) {
  54. var sec01Content = '';
  55. console.log(msg);
  56. var res = msg.length;
  57. console.log(res);
  58. const limit = res;
  59. for (var i = 0; i < limit; i++) {
  60. var numb = i + 1;
  61. sec01Content += ' \
  62. <div class="secimg col-4 col-lg-2 mx-0 px-0"> \
  63. <img id="' + numb + '" class="img-fluid" src="'+msg[i].srcimg+'" alt="">\
  64. </div>';
  65. }
  66. // $('.sec01-designer').html(sec01Content);
  67. // var test = msg[0].newstext1;
  68. // $('#jsontest').append(test);
  69. });
  70. });
  71. // 點選該設計師,導至其對應id的參數網址
  72. $('#1').click(function () { console.log(1);
  73. window.location.href =`./about/index.html?id=1`;
  74. });
  75. $('#2').click(function () { console.log(2);
  76. window.location.href =`./about/index.html?id=2`;
  77. });
  78. $('#3').click(function () { console.log(3);
  79. window.location.href =`./about/index.html?id=3`;
  80. });
  81. $('#4').click(function () { console.log(4);
  82. window.location.href =`./about/index.html?id=4`;
  83. });
  84. $('#5').click(function () { console.log(5);
  85. window.location.href =`./about/index.html?id=5`;
  86. });
  87. $('#6').click(function () { console.log(6);
  88. window.location.href =`./about/index.html?id=6`;
  89. });
  90. $('#7').click(function () { console.log(7);
  91. window.location.href =`./about/index.html?id=7`;
  92. });
  93. $('#8').click(function () { console.log(8);
  94. window.location.href =`./about/index.html?id=8`;
  95. });
  96. $('#9').click(function () { console.log(9);
  97. window.location.href =`./about/index.html?id=9`;
  98. });
  99. $('#10').click(function () { console.log(10);
  100. window.location.href =`./about/index.html?id=10`;
  101. });
  102. $('#11').click(function () { console.log(11);
  103. window.location.href =`./about/index.html?id=11`;
  104. });
  105. $('#12').click(function () { console.log(12);
  106. window.location.href =`./about/index.html?id=12`;
  107. });
  108. $('#13').click(function () { console.log(13);
  109. window.location.href =`./about/index.html?id=13`;
  110. });
  111. $('#14').click(function () { console.log(14);
  112. window.location.href =`./about/index.html?id=14`;
  113. });
  114. $('#15').click(function () { console.log(15);
  115. window.location.href =`./about/index.html?id=15`;
  116. });
  117. $('#16').click(function () { console.log(16);
  118. window.location.href =`./about/index.html?id=16`;
  119. });
  120. $('#17').click(function () { console.log(17);
  121. window.location.href =`./about/index.html?id=17`;
  122. });
  123. $('#18').click(function () { console.log(9);
  124. window.location.href =`./about/index.html?id=18`;
  125. });
  126. $('#19').click(function () { console.log(9);
  127. window.location.href =`./about/index.html?id=19`;
  128. });
  129. $('#20').click(function () { console.log(9);
  130. window.location.href =`./about/index.html?id=20`;
  131. });
  132. $('#21').click(function () { console.log(9);
  133. window.location.href =`./about/index.html?id=21`;
  134. });
  135. $('#22').click(function () { console.log(9);
  136. window.location.href =`./about/index.html?id=22`;
  137. });
  138. $('#23').click(function () { console.log(9);
  139. window.location.href =`./about/index.html?id=23`;
  140. });
  141. $('#24').click(function () { console.log(9);
  142. window.location.href =`./about/index.html?id=24`;
  143. });
  144. $('#25').click(function () { console.log(9);
  145. window.location.href =`./about/index.html?id=25`;
  146. });
  147. $('#26').click(function () { console.log(9);
  148. window.location.href =`./about/index.html?id=26`;
  149. });
  150. $('#27').click(function () { console.log(9);
  151. window.location.href =`./about/index.html?id=27`;
  152. });
  153. $('#28').click(function () { console.log(9);
  154. window.location.href =`./about/index.html?id=28`;
  155. });
  156. $('#29').click(function () { console.log(9);
  157. window.location.href =`./about/index.html?id=29`;
  158. });
  159. $('#30').click(function () { console.log(9);
  160. window.location.href =`./about/index.html?id=30`;
  161. });
  162. $('#30').click(function () { console.log(9);
  163. window.location.href =`./about/index.html?id=30`;
  164. });
  165. $('#31').click(function () { console.log(9);
  166. window.location.href =`./about/index.html?id=31`;
  167. });
  168. $('#32').click(function () { console.log(9);
  169. window.location.href =`./about/index.html?id=32`;
  170. });
  171. $('#33').click(function () { console.log(9);
  172. window.location.href =`./about/index.html?id=33`;
  173. });
  174. $('#34').click(function () { console.log(9);
  175. window.location.href =`./about/index.html?id=34`;
  176. });