jquery实现简单易懂的图片展示小例子
html代码:
. 代码如下:
<body>
<p style="overflow:hidden;width:360px;height:225px;position:absolute;top:30px;" id="p">
<p style="width: 360px; height: 900px; position: relative;" id="imgcon">
<img src="img/1.jpg" id="img0"/>
<img src="img/2.jpg" id="img1"/>
<img src="img/3.jpg" id="img2"/>
<img src="img/1a.jpg" id="img3"/>
<img src="img/1.jpg"/>
</p>
</p>
<p class="box" num="0" id="box0" style="color:red;">1</p>
<p class="box" num="1" id="box1">2</p>
<p class="box" num="2" id="box2">3</p>
<p class="box" num="3" id="box3">4</p>
</body>
js代码:
. 代码如下:
<script type="text/javascript">
$(document).ready(function(){
$("#box0").click(function(){
//$("#imgcon").slideup(4200);
$("#imgcon").animate({top:'-225px'},"slow");
});
$("#box1").click(function(){
$("#imgcon").animate({top:'-450px'},"slow");
});
$("#box2").click(function(){
$("#imgcon").animate({top:'-675px'},"slow");
});
$("#box3").click(function(){
$("#imgcon").animate({top:'-900px'},"slow");
});
});
</script>
css:代码:
. 代码如下:
<style type="text/css">
.box{
width:40px;
height:20px;
border:1px solid #000;
float:left;
cursor:pointer;
}
#imgcon img{
display:block;
padding:0;
margin:0;
width:360px;
height:225px;
}
</style>
上一篇: 详解JavaScript栈内存与堆内存
下一篇: stripos函数知识点实例分享