jquery实现上一页 下一页
2016-07-01 10:49
453 查看
本例为多张图片,只显示一张,相册翻页效果,上一页,下一页,当前页码和总页码
<img src="img/3.gif" alt="" id="cur_img">
<div class="galleryPaging">
<a href="javascript:void(0)" id="LastPage">上一页</a>
<span><em id="pageindex">1</em>/<em id="totalnum">1</em></span>
<a href="javascript:void(0)" id="NextPage">下一页</a>
</div>
var photoimg_str=[{img: 'http://img.oss.shuihulu.com/topic/a224727e07f24c83b41d346e5fe86d41.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/3197a591003e489db0001ad1002ea7f8.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/a58fcc565eca44a89a958552f1724f96.jpg@600w_1l_95Q'},{img:
'http://img.oss.shuihulu.com/topic/3e130f3593c0460586b61c7775c1b7e0.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/e420d9c3f48e4bca8d8ba93c0460727d.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/6231600de694438a99c9bd5bb813852b.jpg@600w_1l_95Q'}];
$("#totalnum").html(photoimg_str.length);
$("#cur_img").attr("src",photoimg_str[0].img);
$("#NextPage").click(function(){
if(parseInt($("#hid_index").val())< parseInt(photoimg_str.length)-1)
{
$("#hid_index").attr("value",parseInt($("#hid_index").val())+1);
$("#cur_img").attr("src",photoimg_str[parseInt($("#hid_index").val())].img);
$("#pageindex").html(parseInt($("#hid_index").val())+1);
}
});
$("#LastPage").click(function(){
if(parseInt($("#hid_index").val())>0)
{
$("#hid_index").attr("value",parseInt($("#hid_index").val())-1);
$("#cur_img").attr("src",photoimg_str[parseInt($("#hid_index").val())].img);
$("#pageindex").html(parseInt($("#pageindex").html())-1);
}
});
<img src="img/3.gif" alt="" id="cur_img">
<div class="galleryPaging">
<a href="javascript:void(0)" id="LastPage">上一页</a>
<span><em id="pageindex">1</em>/<em id="totalnum">1</em></span>
<a href="javascript:void(0)" id="NextPage">下一页</a>
</div>
var photoimg_str=[{img: 'http://img.oss.shuihulu.com/topic/a224727e07f24c83b41d346e5fe86d41.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/3197a591003e489db0001ad1002ea7f8.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/a58fcc565eca44a89a958552f1724f96.jpg@600w_1l_95Q'},{img:
'http://img.oss.shuihulu.com/topic/3e130f3593c0460586b61c7775c1b7e0.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/e420d9c3f48e4bca8d8ba93c0460727d.jpg@600w_1l_95Q'},{img: 'http://img.oss.shuihulu.com/topic/6231600de694438a99c9bd5bb813852b.jpg@600w_1l_95Q'}];
$("#totalnum").html(photoimg_str.length);
$("#cur_img").attr("src",photoimg_str[0].img);
$("#NextPage").click(function(){
if(parseInt($("#hid_index").val())< parseInt(photoimg_str.length)-1)
{
$("#hid_index").attr("value",parseInt($("#hid_index").val())+1);
$("#cur_img").attr("src",photoimg_str[parseInt($("#hid_index").val())].img);
$("#pageindex").html(parseInt($("#hid_index").val())+1);
}
});
$("#LastPage").click(function(){
if(parseInt($("#hid_index").val())>0)
{
$("#hid_index").attr("value",parseInt($("#hid_index").val())-1);
$("#cur_img").attr("src",photoimg_str[parseInt($("#hid_index").val())].img);
$("#pageindex").html(parseInt($("#pageindex").html())-1);
}
});
相关文章推荐
- jquery相关语法实例介绍
- jquery实现图片延迟加载
- JQUERY中find方法
- JS跨域交互(jQuery+php)之jsonp使用心得
- jquery插件省市三级联动
- jQuery mobile的header和footer在点击屏幕的时候消失的解决办法
- JQuery UI autocomplete自动补全插件搜索结果去除提示
- JQuery之添加与删除元素
- 常用的jquery
- jQuery第4节-链接api实现星座运势和手机号归属地查询
- jquery jtemplates.js模板渲染引擎的详细用法第一篇
- jquery tips
- Jquery操作select、checkbox、radio详细讲解
- Jquery noConfict()方法
- jquery总结
- Struts2+jQuery+JSON实现异步交互(找资料看到的一篇不错的文章)
- 第一次想使用插件,就看看啦!jquery-confirm
- JQuery初步
- An invalid form control with name='file[]' is not focusable.间接点击form表单的<input type="file">出现的问题
- 利用 jQuery UI 和 Ajax 创建可定制的 Web 界面