// javascript document //全局js $(function(){ //start if($("#header .nav > ul > li.on").size()){ hoveron("#header .nav > ul > li","#header .nav > ul > li.on"); } //placeholder if('placeholder' in document.createelement('input')==false){ $("input,textarea").each(function(index, element) { if($(this).attr("placeholder")!=undefined){ if($(this).attr("type")!="password"){ $(this).val($(this).attr("placeholder")); $(this).attr("onfocus","if(this.value=='"+$(this).attr("placeholder")+"')this.value=''"); $(this).attr("onblur","if(this.value=='')this.value='"+$(this).attr("placeholder")+"'"); } } }); } $(".passwd").each(function(index, element) { var t=$(this); if('placeholder' in document.createelement('input')==false){ $(this).find(".b").focus(function(){ $(this).hide(); t.find(".a").focus(); }); $(this).find(".a").focus(function(){ t.find(".b").hide(); }); $(this).find(".a").blur(function(){ if($(this).val()==""){ t.find(".b").show(); } }); } else{ t.find(".a").attr("placeholder",t.find(".b").attr("placeholder")); t.find(".b").remove(); } }); // 公用 var _h; $(document).on("click", ".select-box dt a", function (e) { e.preventdefault(); e.stoppropagation(); $(this).parent().toggleclass("open"); $(this).parents(".sc_com").toggleclass("ieopen"); $(this).parent().parent(".select-box").find("dd").toggle(); _h = $(this).parents(".sc_com").find("dd").height() if(_h>240){ $(this).parents(".sc_com").find("dd").addclass("scroll-x") } }) $(document).on("click", ".select-box dd a", function (e) { $(this).addclass("on").siblings().removeclass("on"); $(this).parents(".select-box").find("dt b").html($(this).html()); $(".select-box dt").toggleclass("open"); $(".select-box dd").hide(); $(this).parents(".select-box").find("dt b").css({"color":"#474747"}) }) $(document).on("click",".search_header .sea .btn",function(e){ e.preventdefault(); e.stoppropagation(); $(".input_search").toggleclass("on") }) $(document).on("click",".input_search input,.input_search .btn",function(e){ e.preventdefault(); e.stoppropagation(); }) $(document).click(function () { $(".select-box dt").removeclass("open"); $(".select-box dd").hide(); $(".sc_com").removeclass("ieopen"); $(".input_search").removeclass("on") }) $(".service_com li").hover(function(){ $(this).addclass("on").siblings().removeclass("on"); var _scr = $(this).find("img").attr("src") var _scr2 = $(this).find("img").attr("data-src") $(this).find("img").attr({"src":_scr2}) $(this).find("img").attr({"data-src":_scr}) },function(){ $(this).removeclass("on"); var _scr = $(this).find("img").attr("src") var _scr2 = $(this).find("img").attr("data-src") $(this).find("img").attr({"src":_scr2}) $(this).find("img").attr({"data-src":_scr}) }) settimeout(function(){ var _ind_1 = $(".nav li.on").index(); var _anow = $("a.now").index(); $(".second_nav a").mouseover(function(){ $(".second_nav a.now").removeclass("now") $(this).addclass("now") }); $(".second_nav a").mouseout(function(){ $(this).removeclass("now") $(".nav li").eq(_ind_1).find(".second_nav a").eq(_anow).addclass("now"); }) },30) }); function hoveron(ele,eleon){ var n=$(eleon).index(); $(ele).mouseenter(function(){ $(ele).siblings(".on").removeclass("on") $(this).addclass("on") }); $(ele).mouseleave(function(){ $(this).removeclass("on") $(ele).eq(n).addclass("on").siblings().removeclass("on") }) }