$(document).ready(function () { //返回顶部 $("#backTop").click(function () { $("html,body").animate({ scrollTop: 0 }, 500, function () { }); }) //咨询服务类 侧边栏 $(".nav-sub").each(function () { $(this).parents(".nav-item").addClass("has-two") }) $(".nav-buttom").click(function (e) { e.preventDefault(); if ($(this).parents('.nav-item').hasClass("show")) { $(this).parents('.nav-item').removeClass("show") $(this).parents('.nav-item').find(".nav-sub").slideUp(300) } else { $(this).parents('.nav-item').addClass("show").siblings().removeClass('show') $(this).parents('.nav-item').find(".nav-sub").slideDown(300) $(this).parents('.nav-item').siblings().find(".nav-sub").slideUp(300) } }) $('.has-two').each(function (index) { if ($(this).hasClass("show")) { $(this).find(".nav-sub").slideDown(300) } }) // 灯饰类 侧边栏 $(".mg-item").mouseenter(function (e) { if ($(window).width() > 1200) { $(this).addClass('active').siblings().removeClass('active') } }) $(".mg-item").mouseleave(function () { if ($(window).width() > 1200) { $(this).removeClass('active') } }) $(".mg-item").click(function (e) { if ($(window).width() <= 1200) { e.preventDefault(); if ($(this).hasClass("active")) { $(this).removeClass('active') } else { $(this).addClass('active').siblings().removeClass('active') } } }) $(window).on("load", function () { // 自定义滚动条 $(".content").mCustomScrollbar({ autoDraggerLength: true, }); }); // 二维码 $(".h-one").mouseenter(function (e) { if ($(window).width() > 1200) { $(this).find(".h-code").slideDown(300) } }) $(".h-one").mouseleave(function () { if ($(window).width() > 1200) { $(this).find(".h-code").stop().slideUp(300) } }) $(".h-one").click(function (e) { if ($(window).width() <= 1200) { if ($(this).hasClass("show")) { $(this).removeClass("show") $(this).find(".h-code").slideUp(300) } else { $(this).addClass("show") $(this).find(".h-code").slideDown(300) } } }) $(".h-code").click(function (e) { e.stopPropagation() }) $(".f-icon").mouseenter(function (e) { if ($(window).width() > 1200) { $(this).find(".f-code").slideDown(300) } }) $(".f-icon").mouseleave(function () { if ($(window).width() > 1200) { $(this).find(".f-code").stop().slideUp(300) } }) $(".f-icon").click(function (e) { if ($(window).width() <= 1200) { if ($(this).hasClass("show")) { $(this).removeClass("show") $(this).find(".f-code").slideUp(300) } else { $(this).addClass("show") $(this).find(".f-code").slideDown(300) } } }) $(".f-code").click(function (e) { e.stopPropagation() }) // 入场动画 var hh = $(window).height() $(window).scroll(function (e) { var a = $(this).scrollTop() $(".teaser,.lter,.rter,.scale,.reduce").each(function () { var b = $(this).offset().top if (b - a < hh * 1.1 && b - a > -hh) { var el = $(this) el.addClass("is-visible") setTimeout(function () { el.removeClass("is-visible teaser lter rter scale reduce").addClass("after") //如果原先有transition属性,为防冲突去掉这些类 }, 3000) } else { // $(this).removeClass("is-visible") } }) }) $(window).trigger("scroll") //让IE9支持placeholder $('input, textarea').placeholder(); })