打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
带向左向右方向按钮图片无限循环左右滚动JS代码

<!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=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script>
<style type="text/css">
 body,ul,li { padding:0; margin:0}
 ul,li { list-style:none}
 .img-scroll { position:relative; margin:20px auto; width:440px;}
 .img-scroll .prev,.img-scroll .next { position:absolute; display:block; width:50px; height:100px; background-color:#000;
 top:0; color:#FFF; text-align:center; line-height:100px}
 .img-scroll .prev { left:0}
 .img-scroll .next { right:0}
 .img-list { position:relative; width:320px; height:100px; margin-left:60px; overflow:hidden}
 .img-list ul { width:9999px;}
 .img-list li { float:left; display:inline; width:100px; margin-right:10px; height:100px; background-color:#BDBDDF; text-align:center; line-height:100px;}
</style>
</head>

<body>
<div class="img-scroll">
 <span class="prev">prev</span>
    <span class="next">next</span>
    <div class="img-list">
     <ul>
         <li>阿</li>
            <li>里</li>
            <li>西</li>
            <li>西</li>
        </ul>
    </div>
</div>
<script type="text/javascript">
 function DY_scroll(wraper,prev,next,img,speed,or)
 {
  var wraper = $(wraper);
  var prev = $(prev);
  var next = $(next);
  var img = $(img).find('ul');
  var w = img.find('li').outerWidth(true);
  var s = speed;
  next.click(function()
       {
        img.animate({'margin-left':-w},function()
                  {
                   img.find('li').eq(0).appendTo(img);
                   img.css({'margin-left':0});
                   });
        });
  prev.click(function()
       {
        img.find('li:last').prependTo(img);
        img.css({'margin-left':-w});
        img.animate({'margin-left':0});
        });
  if (or == true)
  {
   ad = setInterval(function() { next.click();},s*1000);
   wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() { next.click();},s*1000);});

  }
 }
 DY_scroll('.img-scroll','.prev','.next','.img-list',3,true);// true为自动播放,不加此参数或false就默认不自动
</script>

</body>
</html>

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Jquery EasyUi实战教程布局篇
JavaScript教程--从入门到精通 4
jQuery基础教程之强大的选择器(层次选择器) | 梦三秋
jquery选择器 之 获取父级元素、同级元素、子元素
Jquery教你写一个简单的轮播.
Jquery插件之可输入的select 《EDITABLE SELECT》
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服