'); } //-------------------------- 所在科室多院区----------------------------------------- $("#index-special .slider").slick({ autoplay: true, slidesToShow: 4, slidesToScroll: 4, speed: 1000, autoplaySpeed: 3000, arrows: true, dots: false, prevArrow: $('#index-special .prev'), nextArrow: $('#index-special .next') }); var once = true; $(window).scroll(function() { var time = 80, windowScroll = window.pageYOffset; if(once) { if(windowScroll > 200 && windowScroll < 950) { action('#index-services li', 0, $('#index-services li').length, 'add', 'scrolled', time); once = false; } } else { if(windowScroll < 50 || windowScroll > 1200) { action('#index-services li', 0, $('#index-services li').length, 'remove', 'scrolled', time); once = true; } } }) function action(which, index, len, act, className, time) { //变量说明:which:哪一个或哪一些元素有动作;index:起始元素索引;len:有动作的元素的长度;act:动作,className:添加的class名;time:一系列动作的间隔 if('[object Array]' === Object.prototype.toString.call(which)) { act=='add'?$(which[index]).addClass(className):''; act=='remove'?$(which[index]).removeClass(className):''; } else { act=='add'?$(which).eq(index).addClass(className):''; act=='remove'?$(which).eq(index).removeClass(className):''; } index ++; if(index < len) { setTimeout(function() { action(which, index, len, act, className, time); },time) } }