您的位置:首页 > Web前端 > JQuery

jQuery滚动图片特效,jQuery无缝(不连续)滚动图片代码

2012-06-23 09:33 501 查看
<!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>
<meta name="author" content="ximan" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<style type="text/css">
*{margin:0;padding:0;}
img{border:none;}
#slide{overflow:hidden;width:900px;margin:100px auto;}
ul{list-style:none;width:2999px;}
li{float:left;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
function AutoScroll(){
var _scroll = $("#slide>ul");
//ul往左边移动300px
_scroll.animate({marginLeft:"-300px"},1000,function(){
//把第一个li丢最后面去
_scroll.css({marginLeft:0}).find("li:first").appendTo(_scroll);
});
}
$(function(){
//两秒后调用
var _scrolling=setInterval("AutoScroll()",2000);
$("#slide>ul").hover(function(){
//鼠标移动DIV上停止
clearInterval(_scrolling);
},function(){
//离开继续调用
_scrolling=setInterval("AutoScroll()",2000);
});
});
</script>
</head>

<body>
<h1><a href="http://ons.me/" target="_blank" title="一个热爱网络的年轻人的博客">西门的后花园</a></h1>
<h2><a href="http://ons.me/299.html" target="_blank">jQuery滚动图片特效,jQuery无缝滚动图片代码</a></h2>
<div id="slide">
<ul>
<li><img src="1.jpg" /></li>
<li><img src="2.jpg" /></li>
<li><img src="3.jpg" /></li>
<li><img src="4.jpg" /></li>
<li><img src="5.jpg" /></li>
</ul>
</div>
</body>
</html>

摘自  http://ons.me/299.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: