$(window).scroll(function(e) { b(); }); function isEmpty (val) { return (typeof val == "undefined" || val == null || val == "")?true:false; } function switchClass(id,c1,c2){ $(id).attr("class",($(id).hasClass(c1))?c2:c1); return false; } function b() { h = $(window).height(); t = $(document).scrollTop(); if (t > h) { $('#zd-gotop').show(); } else { $('#zd-gotop').hide(); } } //判断是否手机浏览器环境 var ua = navigator.userAgent; if(ua.match(/(Mobile|Phone|Windows CE|Opera Mini|BlackBerry|SymbianOS|Palm OS|UCWEB|webOS|MIDP|Touch)/i)){ function switchSearch(){ $.sidr('close', 'sidr-right'); switchClass('#zd-m-nav-search','pmore','none'); $('body').attr("class",($('#zd-m-nav-search').hasClass('none'))?'visi':'hidd'); document.getElementById("kw").focus(); return false; } }else{ } $(function(){ $('#zd-nav-menu').sidr({ name: 'sidr-right', side: 'right', source: '#zd-sidr' }); $(".zd-main").click(function(){ $.sidr('close', 'sidr-right'); }); b(); $('#zd-gotop').click(function() { $('html,body').animate({ scrollTop: '0px' }, 200); }); });