//可以将公用的js 放到这里, 比如tab切换,字号改变,鼠标经过效果…… wsq $(function(){ //掌上医院 $(".historyList").each(function(){ $(this).css("width",158*$(this).find("li").length); }) sollImageBox(".discipCon",".historyList",".leftbtn",".rightbtn",158,158,5000,500,true) }) function sollImageBox(wrapBox,insideBox,toleft,toright,boxWidth,moveWidth,time,sTime,Isauto){ //如果目前宽度不足以滚动,则跳出方法 if($(insideBox).width()0 ? 0 : getMargin()+moveWidth; } else { if(getMargin()==0) { $(toleft).addClass("noPrev"); } else { $(toright).removeClass("noNext"); moveToVal = getMargin()+moveWidth >0 ? 0 : getMargin()+moveWidth; } } } $(insideBox).animate({marginLeft:moveToVal},sTime); } function getMargin(){ return parseInt($(insideBox).css("marginLeft")); } //自动切换 if(Isauto) { $(wrapBox).hover( function(){ clearTimeout(timeObj); }, function(){ timeObj = setInterval(function(){sroolBox('right')},time); } ).trigger("mouseleave"); } $(toleft).click(function(){ sroolBox('left'); }) $(toright).click(function(){ sroolBox('right'); }) }