<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>123</title> </head> <body> <table width="740" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="29"><img src="/Skin/images/yueqi_23.jpg" width="29" height="137" onclick="MarqueeML()" /></td> <td align="center" class="yeqi_main_06"> <div id=demo style="overflow:hidden;width:660px;" align=center> <table border=0 align=center cellpadding=0 cellspacing=0 cellspace=0 width="2500"> <tr><td id=marquePic1> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /> <img src="/Skin/images/yueqi_25.jpg" width="113" height="99" /></td> </tr> </table> </td><td id=marquePic2 valign=top></td></tr> </table></div> <script type="text/javascript"> var speed=50 marquePic2.innerHTML=marquePic1.innerHTML function MarqueeL(){ if(demo.scrollLeft>=marquePic1.scrollWidth){ demo.scrollLeft=0 }else{ demo.scrollLeft++ } } function MarqueeR(){ if(demo.scrollLeft>=marquePic1.scrollWidth){ demo.scrollLeft=0 }else{ demo.scrollLeft-- } } var MyMar=setInterval(MarqueeL,speed) demo.onmouseover=function() {clearInterval(MyMar)} demo.onmouseout=function() {MyMar=setInterval(MarqueeL,speed)} function MarqueeML(){ var MyMar=setInterval(MarqueeL,speed) demo.onmouseover=function() {clearInterval(MyMar)} demo.onmouseout=function() {MyMar=setInterval(MarqueeL,speed)} } function MarqueeMR(){ var MyMar=setInterval(MarqueeR,speed) demo.onmouseover=function() {clearInterval(MyMar)} demo.onmouseout=function() {MyMar=setInterval(MarqueeR,speed)} } </script> </td> <td width="29"><img src="/Skin/images/yueqi_24.jpg" width="29" height="137" onclick="MarqueeMR()" /></td> </tr> </table> </body> </html>
要做一个带左右箭头控制的图片横向滚动效果,点击左箭头图片向左滚动,点击右箭头图片向右滚动,点击左箭头没有问题,点击右箭头有问题,代码要怎么改,请教大家,我对js代码不太熟