// 图片预览展示js $(function(){ // 思路: 获取所有要用的 => 然后通过点击图片显示弹窗 => 赋值到弹窗里面 => 图片赋值 => 文本赋值 $('li .needShowImg').bind('click', function() { $('#imgModal').css('display','block') $('#showImg').css('display','block') $('#showImg2').css('display','none') $('#showImg').attr('src', $(this).attr('src')) $("#caption").text($(this).attr('alt')) }) $('li .needShowImg2').bind('click', function() { $('#imgModal').css('display','block') $('#showImg2').css('display','block') $('#showImg').css('display','none') $('#showImg2').attr('src', $(this).attr('src')) $("#caption").text($(this).attr('alt')) }) $('#imgModalClose').bind('click', function(){ $('#imgModal').css('display','node') }) $('#imgModal').bind('click', function(){ $('#imgModal').css('display','node') }) }) // 菜单js $(function(){ var n=$(".top_nav ul li.cur").index(); $(".top_nav ul li").mouseenter( function(){ $(this).addClass("cur") $(this).siblings().removeClass("cur") } ).mouseleave( function(){ $(".top_nav ul li").eq(n).siblings().removeClass("cur"); $(".top_nav ul li").eq(n).addClass("cur") } ) }) // 侧边栏 $(function(){ $(".side_box").hide() window.onscroll=function(){ var autoheight=document.body.scrollTop||document.documentElement.scrollTop; if(autoheight>240){ $(".side_box").fadeIn(500) }else{ $(".side_box").fadeOut(500) } } $(".sidetop").click( function(){ $('body,html').animate({"scrollTop":0},500); } ) }) //首页-新闻切换表触发事件 $(function () { var $tab_title = $(".tab-title"); var $tab_content = $(".tab-content"); var widths = $(window).width(); $(window).resize(function () { widths = $(window).width(); }) $tab_title.each(function (i) { var $this = $(this); $this.find("li").each(function (w) { var $thisli = $(this); if (widths < 999) { $thisli.click(function () { $thisli.addClass("select").siblings().removeClass("select"); $tab_content.eq(i).find(".tabct").eq(w).show().siblings().hide(); }) } if (widths > 1000) { $thisli.mouseover(function () { $thisli.addClass("select").siblings().removeClass("select"); $tab_content.eq(i).find(".tabct").eq(w).show().siblings().hide(); }) } }) }) }) //js无缝滚动代码 function marquee(i, direction) { var obj = document.getElementById("marquee" + i); var obj1 = document.getElementById("marquee" + i + "_1"); var obj2 = document.getElementById("marquee" + i + "_2"); if (direction == "up") { if (obj2.offsetTop - obj.scrollTop <= 0) { obj.scrollTop -= (obj1.offsetHeight + 20); } else { var tmp = obj.scrollTop; obj.scrollTop++; if (obj.scrollTop == tmp) { obj.scrollTop = 1; } } } else { if (obj2.offsetWidth - obj.scrollLeft <= 0) { obj.scrollLeft -= obj1.offsetWidth; } else { obj.scrollLeft++; } } } function marqueeStart(i, direction) { var obj = document.getElementById("marquee" + i); var obj1 = document.getElementById("marquee" + i + "_1"); var obj2 = document.getElementById("marquee" + i + "_2"); obj2.innerHTML = obj1.innerHTML; var marqueeVar = window.setInterval("marquee(" + i + ", '" + direction + "')", 20); obj.onmouseover = function () { window.clearInterval(marqueeVar); } obj.onmouseout = function () { marqueeVar = window.setInterval("marquee(" + i + ", '" + direction + "')", 20); } }