$(function(){ //折疊QA區塊 $(document).on("click", ".faq-header", function(){ let _this = $(this), item = _this.parents(".faq-item") if(item.hasClass("in-open")){ item.find(".faq-answer").slideUp() item.removeClass("in-open") }else{ $(".faq-item.in-open").find(".faq-answer").slideUp() $(".faq-item").removeClass("in-open") item.find(".faq-answer").slideDown() item.addClass("in-open") } }) //======================= // ajax相關 start //======================= var ajaxUrl = Project_Country + "/support/ajax/ajax_get_qa_list.php", contentBox = $("#QuestionBox"), pageBox = $(".bottom-page") //換頁 $(document).on("click", ".bottom-page .item", function(){ let _this = $(this), page = _this.find(".page").data("page") getQAList(ajaxUrl, contentBox, pageBox, { "page": page, "cid": $('#cid').val(), "type": "" }) }) //選擇類別 $(document).on("change", ".selectbox-select", function(){ let _this = $(this), val = _this.val() getQAList(ajaxUrl, contentBox, pageBox, { "page": 1, "cid": $('#cid').val(), "type": "" }) }) function getQAList(ajaxUrl,contentBox,pageBox,data){ $.ajax({ url: ajaxUrl, type: "POST", cache: false, async: true, dataType: 'json', data: data, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ contentBox.html(d.items) pageBox.html(d.pagebox) } }) } //======================= // ajax相關 end //======================= })