参考代码如下:
<!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>
<title></title>
<script type="text/javascript" language="javascript" src="http://www.codefans.net/ajaxjs/jquery-1.4.2.min.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
$("#right").click(function() {
var roll = $("<div></div>", { css: { position: "absolute", border: "solid 1px #999", left: "806px", top: "10px", height: "494px", width: "1px", background: "#fff"}}).appendTo($("#book").parent())
$(roll).animate({
left: "10px",
width: "398px"
}, 1000, function() {
$("#left").css({"background":"#fff"})
$(roll).fadeOut(300, function() {
$(roll).remove()
})
})
})
})
</script>
</head>
<body style="padding:5pxmargin:0">
<div id="book" style="width:797pxheight:494pxbackground:#cccborder:solid 6px #ccc">
<div id="left" style="width:398pxheight:494pxfloat:leftbackground:url(http://www.codefans.net/jscss/demoimg/201011/PLh.png) no-repeat top leftcursor:pointer"></div>
<div id="right" style="width:398pxheight:494pxfloat:leftbackground:#fffcursor:pointermargin-left:1pxtext-align:right"><p style="margin-top:470pxfont-size:12pxcolor:#999">点这翻页 </p></div>
</div>
</body>
</html>
var img = document.getElementById('image')//获得id为image元素var n = Number(img.title) + n//定义一个变量,值为元素title+自己的值,这里title必须为数字,否则抛出异常,Number()是把字符串类型的数字转为Number类型
if(n <1) n = 4//如果n<1 , n=4
if(n >4) n = 1//如果n>4,n=1 ,这里是一个循环,应该是点到最后一张图片后显示第一张图片
img.src = 'image/'+n+'.jpg'//imgage是文件夹名,n.jpg是文件夹下图片名
img.title = n//改变元素title为n
var a = img.parentNode//定义img的上级节点,应该是一个超链接(<a href=""></a>)
a.href = img.src//为a标记添加href
return false//返回false
<!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" lang="zh-cn">
<head>
<title></title>
<style type="text/css">
img{
width:120px
height:80px
}
.show{
width:595px
height:380px
}
.back{
background-color:blue
width:700px
height:380px
margin:auto
}
.img1{
background-color:red
width:120px
height:80px
margin-left:600px
}
.img2{
background-color:red
width:120px
height:80px
margin-top:20px
margin-left:600px
}
.img3{
background-color:red
width:120px
height:80px
margin-top:20px
margin-left:600px
}
.img4{
background-color:red
width:120px
height:80px
margin-top:20px
margin-left:600px
}
.imgc{
background-color:green
width:595px
height:380px
margin-top:-380px
margin-left:0px
}
</style>
<script type="text/javascript">
var isone = false
var istwo = false
var isthre = false
var isfour = false
window.onload = function(){
var showimg = document.getElementById("showImg")
var one = document.getElementById("cho1")
var two = document.getElementById("cho2")
var thre = document.getElementById("cho3")
var four = document.getElementById("cho4")
one.onmouseover = function(){
isone = true
}
one.onmouseleave = function(){
isone = false
}
two.onmouseover = function(){
istwo = true
}
two.onmouseleave = function(){
istwo = false
}
thre.onmouseover = function(){
isthre = true
}
thre.onmouseleave = function(){
isthre = false
}
four.onmouseover = function(){
isfour = true
}
four.onmouseleave = function(){
isfour = false
}
this.setInterval(function(){
if(isone){
showimg.src = "mm1_002.jpg"
}
if(istwo){
showimg.src = "mm10_002.jpg"
}
if(isthre){
showimg.src = "mm15_002.jpg"
}
if(isfour){
showimg.src = "mm1_002.jpg"
}
},10)
}
</script>
</head>
<body>
<div class="back">
<div class="img1" id="cho1"><img src="mm1_002.jpg"/></div>
<div class="img2" id="cho2"><img src="mm10_002.jpg"/></div>
<div class="img3" id="cho3"><img src="mm15_002.jpg"/></div>
<div class="img4" id="cho4"><img src="mm1_002.jpg"/></div>
<div class="imgc" id="show"><img src="mm1_002.jpg" id="showImg" class="show"/></div>
</div>
</body>
</html>