//下拉菜单 例调用:nav('#nav'); function nav(id){ var onav = $(id); var ali = onav.find('li'); ali.hover(function (){ $(this).addclass('on'); },function (){ $(this).removeclass('on'); }) $('.subnav dd').hover(function(e) { $(this).addclass('current').siblings().removeclass('current'); }); }; //select表单友情链接 例调用:onchange="location1(this)"; //链接网站在新标签页打开 function location1(s) { var d = s.options[s.selectedindex].value; window.open(d); s.selectedindex=0; }; //链接网站在本页面打开 function location2(s) { var d = s.options[s.selectedindex].value; s.selectedindex=0; window.top.location.href = d; }; /*tab切换*/ ;(function($){ $.fn.extend({ tab: function (options){ var defaults = { //默认参数 ev : 'mouseover', //默认事件'mouseover','click' delay : 100, //延迟时间 auto : true, //是否自动切换 true,false speed : 2000, //自动切换间隔时间(毫秒) more : false //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function (){ var o = options; var obj = $(this); var otil = obj.find('.til_tab'); var obox = obj.find('.tablistbox'); var omore = null; var inum = 0; var ilen = otil.length; //鼠标事件绑定 otil.bind(o.ev , function (){ var _this = this; if(o.ev == 'mouseover' && o.delay){ _this.timer = settimeout(function (){ change(_this); },o.delay); }else{ change(_this); }; }) otil.bind('mouseout',function (){ var _this = this; cleartimeout(_this.timer); }); //自动切换效果 (function autoplay(){ var timer2 = null; if(o.auto){ function play(){ inum++; if(inum >= ilen){ inum =0; }; change(otil.eq(inum)); }; timer2 = setinterval(play,o.speed); obj.on('mouseover',function (){ clearinterval(timer2); }) obj.on('mouseout',function (){ timer2 = setinterval(play,o.speed); }) }; })(); function change(box){ inum = $(box).index(); otil.removeclass('on'); obox.css('display','none'); if(o.more){ omore = obj.find('.more_tab'); omore.css('display','none'); omore.eq(inum).css('display','block'); }; otil.eq(inum).addclass('on'); obox.eq(inum).css('display','block'); } }); } }) })(jquery);