var cateNum; var openedQuestion = 0; $(document).ready(function(){ cateCollapse(); var url = window.location.href; var hash = url.substring(url.indexOf("#")+1); if(url.indexOf("#") !== -1){ //console.log(hash); switch(hash) { case "depositactnc": $('.faqcates').removeClass('active'); $('.faqcates').eq(1).addClass('active'); $('.faq-wrapper').eq(1).slideDown( function(){ $("html, body").animate({ scrollTop: $("#timeDES").offset().top - 100}, 500); } ); break; case "generaltnc": $('.faqcates').removeClass('active'); $('.faqcates').eq(0).addClass('active'); $('.faq-wrapper').eq(0).slideDown( function(){ //$("html, body").animate({ scrollTop: $("#timeDESgen").offset().top - 100}, 500); } ); break; } } $('.faqcates').on('click', function () { $('.faqcates').removeClass('active'); $(this).addClass('active'); $('.faq-wrapper').slideUp(); $('.faq-wrapper').eq($('.faqcates').index(this)).slideDown(); cateNum = $(this).index() - 2; $("#faqmobilelist").find('option').eq(cateNum).attr('selected', 'selected'); }); $('#faqmobilelist').on('change', function() { var tarClass = $(this).children("option:selected").val()-1; $('.faq-wrapper').slideUp(); $('.faq-wrapper').eq(tarClass).slideDown(); cateNum = tarClass; $('.faqcates').removeClass('active'); $('.faqcates').eq(tarClass).addClass('active'); }); $('.faq-question-wrapper').on('click', function () { if($(this).next('div').is(":visible")){ $(this).next('div').slideUp(); $(this).next('div').removeClass('watched'); openedQuestion = openedQuestion - 1; }else{ $(this).next('div').slideDown(); $(this).next('div').addClass('watched'); openedQuestion = openedQuestion + 1; } $(this).find('.arrows').toggleClass('rotate90'); if (openedQuestion <= 0){ openedQuestion = 0; $('.faq-collap-all').removeClass('active'); }else{ $('.faq-collap-all').addClass('active'); } }); $('.faq-collap-all').on('click', function () { if ($(this).hasClass('active')){ $('.faq-question-wrapper').next('div').slideUp(); $('.faq-question-wrapper').find('.arrows').removeClass('rotate90'); $('.faq-wrapper').slideDown(); $(this).removeClass('active'); $('#faqmobilelist').prop('selectedIndex',0); openedQuestion = 0; }else{ $(this).addClass('active'); $('.faq-question-wrapper').next('.watched').slideDown(); } }); }); $(window).on('resize', function(){ }); window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { document.getElementById("backToTop").style.display = "block"; } else { document.getElementById("backToTop").style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { $('body,html').animate({scrollTop:0},500); } function cateCollapse(){ var cateLength = $('.faqcates').length; var opts = ''; var i; var fake_i; //create option for (i = 0; i < cateLength; i++) { fake_i = i + 1; opts = opts + ''; } $('#faqmobilelist').html(opts); if ($(document).width() <= 992) { } }