需要添加jquery文件才可以调试 复制代码 代码如下: <br>$(function(){ <br>//alert($('#findclose').closest('div').attr('id')); <br>var pic_length = $('#gd li').length; <br>var n = 0; <br>$('#toleft').click(function(){ <br>if (!$('#gd').is(':animated ') && n) <br>{ <br>$('#gd').animate({left:' =120px'},500 <br>n--; ; <br>$('#toright').click(function(){ <br>if (!$('#gd').is(':animated') && pic_length > n 5) <br>{ <br>$('#gd').animate({left:'-=120px'},500); <br>n ; <br>} <br>}); ;/script> <br><style type="text/css"> <br>ul{ <br>list-style:none; <br>marge:0px; <br>padding:0px; <br>text-align:center; <br>} <br>#gd li { <br>width:90px; <br>Höhe:80px; <br>display:block; <br>float:left; <br>Rand: 9px 15px; <br>} <br></style> <br><div style="width:702px;height:100px;background:#ccc;margin:0 auto"> <br><div style="width:30px;height:30px;background:red;margin:35px 10px;float:left;cursor:pointer;" id="toleft"></div> <br><div style="width:600px;height:98px;float:left;border:1px solid #777;overflow: versteckt;"> <br><ul style="list-style: none Outside none;height:98px;display:block;background:yellow;position:relative;width:9999em;" id="gd"> <br><li style="background:red"></li> <br><li style="background:orange"></li> <br><li style="background:green"></li> <br><li style="background:navy"></li> <br><li style="background:blue"></li> <br><li style="background:purple"></li> <br><li style="background:pink"></li> <br><li style="background:gray"></li> <br></ul> <br></div> <br><div style="width:30px;height:30px;background:red;margin:35px 10px;float:left;cursor:pointer;" id="toright"></div> <br></div> <br><br> </div>