$(document).ready(function() { /*------------------------- heroheader -------------------------*/ $(".hamburger").click(function(){ $(".navbox").addClass("show"); }); $(".close_hamburger").click(function(){ $(".navbox").removeClass("show"); }); $(".dropBt").on('click',function(e) { e.preventDefault(); $(this) .siblings(".haveDrop") .toggleClass("open"); $(this) .closest(".toggleIcon") .toggleClass("closebt"); $(this) .parent() .siblings() .find(".dropBt") .removeClass("active"); $(this) .parent() .siblings() .find(".haveDrop") .removeClass("open"); $(this) .parent() .siblings() .find(".toggleIcon") .removeClass("closebt"); }); $(".navbox").on('mouseleave', function() { // 移除之前添加的类 $(".haveDrop").removeClass("open"); $(".toggleIcon").removeClass("closebt"); $(".dropBt").removeClass("active"); }); $(".mod-language").click(function () { $(".language-content").toggle(200); }); $(".mod-language").on('mouseleave', function() { $(".language-content").hide(200); }); $(".mod-message").click(function () { $(".message-content").toggle(200); }); $(".mod-message").on('mouseleave', function() { $(".message-content").hide(200); }); $(".lineshare").click(function () { $(".lineshare-content").toggle(200); }); $(".lineshare").on('mouseleave', function() { $(".lineshare-content").hide(200); }); $(".membernav").click(function () { $(".lists").toggle(200); }); // $(".membernav").on('mouseleave', function() { // $(".lists").hide(200); // }); $(".moreopen").click(function () { $(this).find('.more-inner').toggle(200); }); $(".ic_more").click(function () { $(".sidenav").toggle(200); }); $('.ringopen').click(function() { $(this).closest('.items').find('.drop').toggle(200); $(this) .parent().parent() .siblings() .find(".drop") .hide(200); $(this).closest('.items').find('.ringopen').toggleClass('show'); $(this) .parent().parent() .siblings() .find(".ringopen") .removeClass('show'); }); $('.titleopen').click(function() { $(this).parent().find('.drop').toggle(200); $(this) .parent().parent() .siblings() .find(".drop") .hide(200); $(this) .parent().parent() .siblings() .find(".ringopen") .removeClass('show'); }); /*------------------------- 首頁大圖輪撥 -------------------------*/ var swiper = new Swiper(".Swiperkv", { loop: true, autoplay: { delay: 8000, disableOnInteraction: false, }, pagination: { el: ".swiper-pagination", }, }); /*------------------------- 首頁-tab選單 -------------------------*/ $(".tab").click(function(){ // 移除所有內容的顯示 $(".content").removeClass("active").hide(); // 顯示選擇的內容 let contentId = $(this).data("content"); $("#" + contentId).addClass("active").show(); // 更新頁簽的樣式 $(".tab").removeClass("active"); $(this).addClass("active"); }); /*------------------------- 會員頁sidemenu當前頁面位置 -------------------------*/ $(".userNav a").each(function() { if ($(this).attr("href") == window.location.pathname.split("/")[1]) $(this).addClass("active"); }); /*------------------------- 類別選單 -------------------------*/ var swiper = new Swiper(".categorySwiper", { slidesPerView: 4, spaceBetween: 12, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, breakpoints: { 640: { slidesPerView: 5, spaceBetween: 0, }, 720: { slidesPerView: 12, spaceBetween: 0, }, }, }); var swiper = new Swiper(".categorySwiper2", { slidesPerView: 2, spaceBetween: 12, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, breakpoints: { 680: { slidesPerView: 5, spaceBetween: 12, }, }, }); var swiper = new Swiper(".categorySwiper3", { slidesPerView: 2, spaceBetween: 1, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, breakpoints: { 640: { slidesPerView: 5, spaceBetween: 1, }, }, }); /*------------------------- lightbox -------------------------*/ $(".lightbox-close").click(function () { $(".lightbox-target").removeClass('lightboxopen'); }); $(".newmargin").click(function () { $(".lightbox-margin").addClass('lightboxopen'); }); $(".esgfuture").click(function () { $(".lightbox-esgfuture").addClass('lightboxopen'); }); /*------------------------- FAQ -------------------------*/ $("li.a").hide(); $("li.q").click(function() { //gets next element //opens .a of selected question $(this) .next() .slideToggle(500) //selects all other answers and slides up any open answer .siblings("li.a") .slideUp(); //Grab img from clicked question var img = $(this).children("i"); //Remove Rotate class from all images except the active $("i") .not(img) .removeClass("rotate"); //toggle rotate class img.toggleClass("rotate"); }); /*------------------------- 文件ready ok jquery結束 -------------------------*/ });