$('.f-weixin').click(function () { $('.code').show() }) $('.code').click(function () { $(this).hide() }); $(".pcnav_u1_2r").each(function () { $(this).find('.pcnav_3').eq(0).show(); }); $('.pcnav_u1_2l li').hover(function () { var index = $(this).index(); $(this).parent().next().find('.pcnav_3').hide(); $(this).parent().next().find('.pcnav_3').eq(index).show() }); $('.n-nav-btn').click(function () { var isactive = $(this).parent().attr('class') == 'n-nav-item active' ? true : false; if(isactive){ $(this).parent().attr('class','n-nav-item'); $(this).parent().find('ul').slideup(); }else { $(this).parent().attr('class','n-nav-item active'); $(this).parent().find('ul').slidedown(); } }); $('.n-nav-btn2').click(function () { var str = $(this).html(); if(str == '展开'){ $('.n-nav').addclass( 'active'); $(this).html('收起'); }else { $('.n-nav').removeclass( 'active'); $(this).html('展开'); } }); /*! * globalmethod javascript library v1.0.1 * * includes jquery.js * * date: 2018-12-19t19:00z */ // var globalmethod = !function ($, fn) { (fn($))() }(jquery, function () { var version = "1.0.1", gmethod = function () { }; gmethod.fn = gmethod.prototype = { constructor: gmethod, data: { topnum: 80 }, init: function () { console.log(this); this.binddom(); this.addevent(); this.wscroll(); this.imgw(); this.getwidth() }, binddom: function () { this.$totop = $('.totop'); this.$inav = $(".i-nav"); this.$divlink = $(".divlink"); this.navbtn = $('.nav-btn'); this.$img = $('img'); }, addevent: function () { const base = this // 手机导航按钮 this.navbtn.on('click', function () { $('.nav-table-cell').toggleclass('close'); $('.mynav-ul').toggleclass('shownav'); }); //回到顶部 this.$totop.click(function () { this.totop(0); }); //锚点索引 this.$divlink.click(function () { var m = $(this).attr('data'); var t = $(m).offset().top - base.topnum; base.totop(t); }); }, imgw: function () { this.$img.each(function () { var w = $(this).attr('width'); var h = $(this).attr('height'); if (w) { $(this).css({'width': w + 'px', 'height': h + 'px', 'max-width': '100%'}) } }); }, getwidth(){ this.topnum = window.innerwidth > 1200 ? 80 : 60; }, wscroll: function () { $(window).scroll(() => { var scroll_height2 = document.body.scrolltop; var scroll_height = document.documentelement.scrolltop; if(scroll_height <= 1 || scroll_height2 <= 1){ // $('.pcnav').css({'top': '0'}); } if (scroll_height >= 80 || scroll_height2 >= 80){ $('.pcnav').addclass('active'); }else { $('.pcnav').removeclass('active'); } }); }, totop: function (t) { $("html, body").animate({scrolltop: t}, {duration: 500, easing: "swing"}); return false; } }; gmethod.prototype.init(); return gmethod });