| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- $(function () {
- // menu
- $(".m-header i").click(function () {
- $(".mob-navigation").addClass("on");
- $("body").css('overflowY','hidden');
- });
- $(".mob-navigation .home").click(function () {
- $(".mob-navigation").removeClass("on");
- $("body").css('overflowY','scroll');
- });
- $('.free-tel,.zixun').click(function () {
- document.getElementById('liuyanForm').reset();
- $(".spot-bg").css("display", "block");
- $('.fixed-foot').addClass('fixed-foot-on');
- })
- $(".spot-bg,.fixed-foot i").click(function () {
- $(".spot-bg").css("display", "none");
- $('.fixed-foot').removeClass('fixed-foot-on');
- })
- $(".trade-nav-l ul li").click(function(){
- var index = $(this).index();
- console.log(index)
- $(this).addClass('on').siblings().removeClass('on');
- $(".trade-nav-r .trade-list-box").eq(index).addClass('on').siblings().removeClass('on');
- })
- /*$("img").each(function(k,item){
- var _this = $(this);
- var src = _this.attr('data-src');
- if(src){
- setTimeout(function(){
- _this.attr('src', src);
- },1)
- }
- })*/
- var num = document.getElementsByTagName('img').length;
- var img = document.getElementsByTagName("img");
- var n = 0; //存储图片加载到的位置,避免每次都从第一张图片开始遍历
- lazyload();
- function lazyload() { //监听页面滚动事件
- var seeHeight = document.documentElement.clientHeight; //可见区域高度
- var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; //滚动条距离顶部高度
- for (var i = n; i < num; i++) {
- if (img[i].offsetTop < seeHeight + scrollTop) {
- var src = img[i].getAttribute("src");
- if (src == "" || typeof(src) == 'undefined' || src==null) {
- img[i].src = img[i].getAttribute("data-src");
- }
- n = i + 1;
- }
- }
- }
- // 回顶部
- $('.go-top').click(function () {
- $('body,html').animate({ scrollTop: 0 });
- })
- $(window).scroll(function () {
- var oTop = document.body.scrollTop == 0 ? document.documentElement.scrollTop : document.body.scrollTop;
- if (oTop > 200) {
- $('.go-top').fadeIn();
- } else {
- $('.go-top').fadeOut();
- }
- })
- })
|