if(typeof $ != "undefined") {; $(function() { var width = $(window).width(); var win = $(window); var isie = !!window.activexobject; var isie6 = isie && !window.xmlhttprequest; var isie8 = isie && !!document.documentmode; var isie7 = isie && !isie6 && !isie8; // funhead if(width > 800) { (function() { var win = $(window); var header = $("#header"); if(header.length > 0 && header.hasclass("tofixed")) { var headertop = header.offset().top, headerheight = header.height(), headerfixedtop = headertop + headerheight; var headerwrap = $("#headerwrap"); headerwrap.length > 0 ? function() { headerwrap.height(headerheight); }() : 0; win.on("load scroll resize", function() { $(this).scrolltop() >= headerfixedtop ? function() { !header.hasclass("header_fixed") ? header.addclass("header_fixed") : 0; }() : function() { header.removeclass("header_fixed") }(); if(isie6) { var scrollt = $(this).scrolltop(); scrollt >= headerfixedtop ? function() { header.css({ "top": scrollt + "px" }); }() : function() { header.css({ "top": "0px" }); }(); }; }); }; })(); } // end funhead // ftool (function() { var ftool = $("#ftool"), ftooltop = $("#ftooltop"); ftooltop.click(function(e) { e.preventdefault(); $("html,body").animate({ scrolltop: 0 }, 500); }); $(window).on("domcontentloaded scroll resize", function() { $(this).scrolltop() == 0 ? ftooltop.stop(true, true).fadeout() : ftooltop.fadein(); $(this).scrolltop() < 320 ? ftool.stop(true, true).fadeout() : ftool.fadein(); }); // ie6 if(isie6) { $(window).scroll(function() { $("#ftool").css({ "top": $(this).scrolltop() + 200 }); }); }; })(); // end ftool }); }; // end jq //改造;闭包+封装 function tab_click(clickobj, showobj, info) { (function() { var exports = {}; //隐藏所有 exports.hideobj = function() { $(showobj).hide(); } //显示第一个 exports.showone = function() { $(showobj).eq(0).show(); } //点击时选择给on exports.clickobj = function() { $(clickobj).click(function() { var indes = $(this).index(); $(this).addclass('on').siblings().removeclass('on'); exports.showobj(indes); return indes; }); }; //显示隐藏 exports.showobj = function(inde) { $(showobj).eq(inde).fadein().siblings().hide(); }; exports.hideobj(); exports.showone(); exports.clickobj(clickobj); }()); }