<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			ul{
				list-style: none;
			}
			#box{
				width: 500px;
				border: 1px solid red;
				margin: 40px auto;
				overflow: hidden;
				position: relative;
				height: 300px;
			}
			#list{
				width: 2500px;
				height: 300px;
				border: 1px solid blue;
				position: absolute;
			}
			#list li img{
				float: left;
				width: 500px;
				height: 300px;
				text-align: center;
				line-height: 300px;
				font-size: 40px;	
			}
			#list2{
				width: 120px;
				position: absolute;right: 180px;bottom: 10px;
				z-index: 999;
			}
			#list2 li{
				width: 18px;
				height: 20px;
				background: red;
				border-radius: 40%;
				float: left;
				margin: 2px;
				cursor: pointer;
			}
		</style>
		<script src="common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			window.onload = function(){
				var oList = $(‘list‘),
					oList2= $(‘list2‘),
					oLi	  = oList2.children,	
					oTimer=null,
					//oFirst= oList.firstElementChild,
					iIndex=0;
				
					
				for(let i=0;i<oLi.length;i++){	
					oLi[i].onmouseover = function(){
						clearInterval(oTimer);
						oList.style.left=i*(-500)+‘px‘;
						//oLi[iIndex].style.backgroundColor = "#f00";
					};
					oLi[i].onmouseleave = function(){
						oTimer=setInterval(function(){
					if(iIndex ===5){
						iIndex=0;
						oList.style.left=0;
					}
					bufferMove(oList,{left:-500*iIndex});
					iIndex++;
					},2000)
					}
				};
				//oList.innerHTML += oFirst.outerHTML;
				//for(var i=0;i<oLi.length;i++){
			
				oTimer=setInterval(function(){
					if(iIndex ===5){
						iIndex=0;
						oList.style.left=0;
					}
					bufferMove(oList,{left:-500*iIndex});
					iIndex++;
					},2000)
				//}
				
			}
		</script>
	</head>
	<body>
		<div id="box">
			<ul id="list">
				<li>
					<img src="img/1.jpg"/>
				</li>
				<li>
					<img src="img/2.jpg"/>
				</li>
				<li>
					<img src="img/3.jpg"/>
				</li>
				<li>
					<img src="img/4.jpg"/>
				</li>
				<li>
					<img src="img/5.jpg"/>
				</li>
			</ul>
			<ul id="list2">
				<li></li>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
			</ul>
		</div>
	</body>
</html>
原文:http://www.cnblogs.com/xcbk/p/6726932.html