$(document).ready(function () { //让IE9支持placeholder $('input, textarea').placeholder(); $(".h-menu").click(function () { $("header").addClass("show-menu") }) $(".h-opa").click(function () { $("header").removeClass("show-menu show-search show-lang") }) $(".h-s").click(function () { $("header").addClass("show-search") setTimeout(function () { $(".h-m").focus(); }, 300) }) $(".h-l").on("click", function () { $("header").addClass("show-lang") }) //是否有二级菜单,有显示下拉箭头 $(".h-sub").each(function () { $(this).parents(".h-d").addClass("has-nav") }) $(".has-nav").click(function (e) { if ($(window).width() <= 1100) { e.preventDefault(); if ($(this).hasClass("show")) { $(this).removeClass("show") $(this).find(".h-sub").slideUp(300) } else { $(this).addClass("show") $(this).find(".h-sub").slideDown(300) } } }) $(".h-sub").click(function (e) { e.stopPropagation() }) $(".has-nav").mouseenter(function (e) { if ($(window).width() > 1100) { $(this).find(".h-sub").stop().slideDown(300) } }) $(".has-nav").mouseleave(function () { if ($(window).width() > 1100) { $(this).find(".h-sub").stop().slideUp(300) } }) $(".n-link").click(function () { $(this).addClass("active").siblings().removeClass("active") }) }); $(document).ready(function () { $(document).on('click', '#SearchBtn', function () { if ($('body').hasClass('SearchShow')) { $('body').removeClass('SearchShow'); } else { $('body').addClass('SearchShow'); } }); $(document).on('click', '.FormBox .exit', function () { $('body').removeClass('SearchShow'); }); $('.top_btn').bind('click', function () { $('html,body').animate({ scrollTop: 0 }); }); //置顶 $(".menu_btn").click(function () { $("header").addClass("show-menu") }); }) // $(".ha_link").click(function () { // $("html, body").animate({ // scrollTop: $($(this).attr("href")).offset().top - 20 + // "px" // }, 500); // return false; // }); ///**滚动**/ // $(window).scroll(function () { // scroll_fun(); // }); // function scroll_fun() { // var srctop = $(window).scrollTop(); // if (srctop > 100) { // $('body').addClass('SmallHeader'); // } else { // $('body').removeClass('SmallHeader'); // } // } // scroll_fun(); $(window).scroll(function (e) { var hh = $(window).height() var a = $(this).scrollTop() $(".teaser,.teaser2,.lter,.rter").each(function () { var b = $(this).offset().top if (b - a < hh * 0.99 && b - a > -hh) { var el = $(this) el.addClass("is-visible") setTimeout(function () { el.removeClass("is-visible teaser2 teaser lter rter").addClass("after") }, 2000) } else { // $(this).removeClass("is-visible") } }) }); $(window).on("load", function () { $(window).trigger("scroll"); }); function lazy() { var w = $(window) $("[data-src]").each(function () { var a = $(this) if (!a.attr("done") && (w.scrollTop() + w.height() > a.offset().top)) { a.attr("done", "done") var src = a.attr("data-src") if (a[0].nodeName == 'IMG') { a.attr("src", src) } else { a.css("backgroundImage", "url(" + src + ")") } } }) } $(window).scroll(lazy) lazy(); // 数字滚动 function f_num(selector) { listen(); function listen() { $(selector).each(function (i, el) { if ($(el).data('done')) { return; } if ($(el).offset().top - $(document).scrollTop() < $(window).height()) { $(el).data('done', true); change(el) } }) }; function change(el) { var value = $(el).data('num') if (value) { value = Number(value); var valNow = 0; var timer = ''; var duration = 1500; var speed = 50; var num = Math.floor(duration / speed); if (num > value) { num = value; } var add = parseInt(value / num); var i = 0; timer = setInterval(function () { if (i == num) { $(el).html(value); clearInterval(timer) } else { valNow += add; $(el).html(valNow); i++; } }, speed) } }; $(window).on('scroll', function () { listen() }); };