我正在尝试pagination
通过上传图像并将它们添加到容器中,方法是通过使用新创建新div
并id's
提供第一页来制作class
如下所示的内容。current
如果我更改到新页面,则将活动类删除到当前页面并将其添加到所选页面。
我想知道如何删除所有inactive
没有“当前”类的页面
这是我的代码:
<script type="text/javascript">
var imagesPerPage = 4, pageNumber = 1;
function onAjaxSucceded(data) {
var pagesContainer = $('#pagesContainer'),
imagesInPage = 0,
divPage = $("#p1");
$.each(data.result, function(index, file) {
if (imagesInPage >= imagesPerPage) {
imagesInPage = 1;
pageNumber += 1;
divPage = $('<div/>', {id : "p" + pageNumber}).addClass('pagedemo').hide().appendTo(pagesContainer);
} else {
imagesInPage += 1;
}
var src = 'Uploads/' + file.name;
$('<img>', {src: src, href: src, "class": 'LoadclickImage', align: 'left'}).appendTo(divPage);
});
$("#demo5").paginate({
count: pageNumber,
start: 1,
display: Math.min(7, pageNumber),
border: true,
border_color: '#fff',
text_color: '#fff',
background_color: 'black',
border_hover_color: '#ccc',
text_hover_color: '#000',
background_hover_color: '#fff',
images: false,
mouse: 'press',
onChange: function(page) {
$('#paginationdemo ._current').removeClass('_current').hide();
$('#p' + page).addClass('_current').show();
}
});
}
var fakeAjaxData = {
result: [
{name: '../../../img/keys.png'},
{name: '../../../img/logo.png'},
{name: '../../../img/input-button-bg.png'},
{name: '../../../img/remove-resources.png'},
{name: '../../../img/logo.png'},
{name: '../../../img/input-button-bg.png'},
{name: '../../../img/remove-resources.png'},
{name: '../../../img/keys.png'},
{name: '../../../img/keys.png'},
{name: '../../../img/input-button-bg.png'},
{name: '../../../img/logo.png'},
{name: '../../../img/remove-resources.png'},
{name: '../../../img/keys.png'},
{name: '../../../img/keys.png'},
{name: '../../../img/input-button-bg.png'},
{name: '../../../img/logo.png'},
{name: '../../../img/remove-resources.png'},
{name: '../../../img/input-button-bg.png'},
{name: '../../../img/logo.png'},
]
};
$(function() {
onAjaxSucceded(fakeAjaxData);
});
</script>
这是我的演示
编辑:
任何人都可以代替removing
inactive
课堂说我如何删除所有页面,如果我再次添加,我需要从1st page.
现在开始添加图像如果我删除它从它添加的最后一页添加的页面。
对不起,如果我的标签是错误的。