$(window).load(function(){ // assign the slider to a variable var slider = $('#slider2').bxSlider({ mode: 'horizontal', auto: true, responsive: true, pause: 4000, speed: 1000, prevText: '', nextText: '', pager: true, //easing: 'easeOutBounce', pagerCustom: '.bx-pager', onSlideAfter: function () { slider.startAuto();} }); }); $(function(){ $(window).scroll(function (){ $('.fadein').each(function(){ var elemPos = $(this).offset().top; var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); if (scroll > elemPos - windowHeight + 100){ $(this).addClass('scrollin'); } }); }); }); $(function() { var topBtn = $('#page-top'); topBtn.hide(); $(window).scroll(function () { if ($(this).scrollTop() > 100) { topBtn.fadeIn(); } else { topBtn.fadeOut(); } }); topBtn.click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); }); $(function(){ var $setElem = $('.switch'), pcName = '_pc', spName = '_sp', replaceWidth = 641; $setElem.each(function(){ var $this = $(this); function imgSize(){ if(window.innerWidth > replaceWidth) { $this.attr('src',$this.attr('src').replace(spName,pcName)).css({visibility:'visible'}); } else { $this.attr('src',$this.attr('src').replace(pcName,spName)).css({visibility:'visible'}); } } $(window).resize(function(){imgSize();}); imgSize(); }); });