$(function () { function isie() { if (!!window.activexobject || "activexobject" in window) return true; else return false; } if (isie()) { $('#header .search-box input').val('请输入关键词') } function searchshowfun ($this) { $this.hover(function () { var width_docu = $(document).width() $(this).find('.drop-wrap').show() var diff = 2 if (isie()) { diff = 20 } var width_input = $(document).width() - $(this).position().left - diff $(this).find('.drop-wrap').css({width: width_input + 'px'}) $(this).find('.drop-wrap').each(function (index, that) { var width = 0 $(that).find('a').each(function (index, obj) { width += $(obj).outerwidth(true) }) width += 50 if (width >= width_input) { $(that).css({width: width + 'px'}) } if (width_docu < $(document).width()) { // $(that).css({right: 0, left: 'auto'}) $(that).css({right: 0}) } }) }, function () { $(this).find('.drop-wrap').hide() }) } searchshowfun($('#header .top-nav_item')) $('.open-menu, .page-link').click(function () { if ($(this).data('index')) { $('.mobile-nav .top-nav_item').eq($(this).data('index')).click() } $('.open-menu').hide() $('.close-menu').show() $('.mobile-nav').addclass('active') }) $('.close-menu').click(function () { $(this).hide() $('.open-menu').show() $('.top-nav_item').add('.mobile-nav_list').removeclass('on') $('.mobile-nav').removeclass('active') }) $('.top-nav_item.has-drop').click(function (e) { // e.preventdefault() $(this).add('.mobile-nav_list').addclass('on') }) $('.mobile-nav_list .go-pre').click(function () { $('.top-nav_item').add('.mobile-nav_list').removeclass('on') }) //加载更多 $('.ajax-load-more').on('click', function () { var _this = this, url = $(_this).attr('href'), container = $(_this).data('container'), page = $(this).data('page'); page++; $(_this).hide(); $('.ajax-loading').show(); $.get(url, {page: page}, function (html) { $(_this).data('page', page).show(); var html = $.trim(html); if (html) { $('.ajax-loading').hide(); $(container).append(html); } else { $(_this).hide(); $('.ajax-loading').text('已全部加载完毕'); } }) return false }); })