你好 - 首先,我相当新的jQuery,所以你的扩展的专业知识非常感谢。jquery:将滑动列表添加到滑动div
DEMO:http://www.transcendspace.com/beta/
我想生成用于我的div一个导航:1 | 2 | 3 | 4 | 5等,其将突出的数目取决于哪个格是有效的。理想情况下,突出显示将与左/右箭头结合使用。
CODE:`
$(document).ready(function() {
$(window).resize(function() {
resizePanel();
});
});
function resizePanel() {
width = $(window).width();
height = $(window).height();
mask_width = width * $('.item').length;
$('#debug').html(width + ' ' + height + ' ' + mask_width);
$('#wrapper, .item').css({width: width, height: height});
$('#mask').css({width: mask_width, height: height});
$('#wrapper').scrollTo($('a.selected').attr('href'), 0);
}
function scrollToPosition(element) {
if (element !== undefined) {
$("#wrapper").scrollTo(element, 800, {});
}
}
$(function() {
//Create an Array of posts
var posts = $('.item');
var position = 0; //Start Position
var next = $('#next');
var prev = $('#prev').hide();
//Better performance to use Id selectors than class selectors
next.click(function(evt) {
//Scroll to next position
prev.show();
scrollToPosition(posts[position += 1]);
if (position === posts.length - 1) {
next.hide();
}
});
prev.click(function(evt) {
//Scroll to prev position
next.show();
scrollToPosition(posts[position -= 1]);
if (position === 0) {
prev.hide();
}
});
});
</script>'
谢谢期待你的答复!我已经提前更新了我的代码,并且正在抓取我的物品。我尝试在.click中使用:'(this).data.scrollTo('item');'但是不幸的是这种方式不起作用,我在.click中添加了我的呼叫 - 同样,我对此很陌生,但是我非常感谢你的帮助。更新:[链接](http://www.transcendspace.com/beta) – user174242
要获得'数据项'值,你必须做'.data('item')'。检查[.data()](http://api.jquery.com/data/)文档。 –
我已经更新了我的答案和更多信息。如果有帮助,请接受答案,是吗? –