// 手機板menu彈跳視窗 $("#menu-box2").hide(); $("#menu-box").hide(); $(".link").click(function () { $("#menu-box").fadeOut("slow", function () { $("#menu-box2").fadeOut("slow"); // Animation complete. }); }); $("#menu-btn1").click(function () { $("#menu-box").fadeIn(); $("#menu-box2").fadeIn(); }); $(".close").click(function () { $("#menu-box").fadeOut(); $("#menu-box2").fadeOut(); }); // sec01 最新課程手機輪播 $('#sec01-moblie-container').slick({ arrows: false, slidesToShow: 1, slidesToScroll: 1, infinite: false, centerMode: true, }); $('#sec01-slider-next').click(function () { $('#sec01-moblie-container').slick('slickNext') }); // sec04 專欄報導 手機輪播 $('#sec04-moblie-container').slick({ arrows: false, slidesToShow: 1, slidesToScroll: 1, infinite: false, centerMode: true, }); $('#sec04-slider-next').click(function () { $('#sec04-moblie-container').slick('slickNext') }); // sec03排名table輪播 $('#sec03-slider').slick({ arrows: false, slidesToShow: 1, slidesToScroll: 1, infinite: true, }); $('#sec03-slider-next').click(function () { $('#sec03-slider').slick('slickNext') }); $("*").each(function (index, element) { // 此元素被點選後執行 $(this).click(function (e) { // 取得被點選元素的屬性:data-gt-target var target = $(this).attr("data-gt-target"); var duration = $(this).attr("data-gt-duration"); var offset = $(this).attr("data-gt-offset"); // JS 語法:判斷式 // if (條件) {程式區塊} // 當條件成立,會執行程式區塊 // 如果 目標有資料 才會執行 { } 內的程式 // 避免出現 undefine (未定義 - 不存在的資料) if (target) { //console.log("目標:" + target); //console.log("時間:" + duration); //console.log("位移:" + offset); // 上方位置 = 目標區塊.位移().上方位置 var top = $(target).offset().top; //console.log("要前往元素的上方位置:" + top); // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間) // parseInt() 將文字轉為數字 $("html").stop().animate({ scrollTop: top - offset }, parseInt(duration)); } }); }); // 避免動畫與使用者滾輪衝突 // html 在滾動滾輪時 停止 html 所有效果 $("html").on("mousewheel", function () { $("html").stop(); }); // 點擊次數增加JS $(document).on("click", ".course-src", function (event) { var courseid = $(this).data("info"); console.log(courseid); var url = "https://welife.asia:8002/course_click/" + courseid + ""; var xhr = new XMLHttpRequest(); xhr.open("GET", url); xhr.setRequestHeader("accept", "application/json"); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { console.log(xhr.status); console.log(xhr.responseText); } }; xhr.send(); }); $.fn.serializeObject = function () { var o = {}; var a = this.serializeArray(); // o["id"] = 0; // o["time_stamp"] = ""; $.each(a, function () { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; $(".email-sub").submit(function (e) { /* var formRef = $('#form1').serializeArray(); var jsonString = JSON.stringify(formRef);*/ var jsonInfo = $('.email-sub').serializeObject(); tag_str = '' jsonInfo.tags.forEach(function (value) { tag_str += value + ','; }); jsonInfo.tags = tag_str.slice(0, -1) var jsonString = JSON.stringify(jsonInfo); console.log(jsonString), $.ajax({ type: 'POST', url: 'https://welife.asia:8002/email_interest', data: jsonString, dataType: 'json', success: function (data) { console.log('送出成功: ' + data); alert("訂閱成功"); location.reload(); }, beforeSend: function () { console.log('beforeSend'); }, complete: function () { console.log('complete'); }, error: function (jqXHR, textStatus, errorThrown) { console.log(JSON.stringify(jqXHR)); console.log("AJAX errr: " + textStatus + ' : ' + errorThrown); console.log('送出失敗: ' + jqXHR.responseText); } }); return false; }); $( ".close-adv" ).click(function() { $( ".courseadv" ).hide(); });