我的代码不起作用。我想要的是在点击#prev_pag
和#next_pag
后将我的分页移到左侧和右侧。我不知道为什么这段代码不起作用?
示例: http://jsfiddle.net/szVKD/
JS代码:
$('#next_pag').click(function() {
$('#pagination').animate({
marginLeft: '-=100px'
},
500);
});
$('#prev_pag').click(function() {
$('#pagination').animate({
marginLeft: '+=100px'
},
500);
});
});
答案 0 :(得分:0)
$('#next_pag').click(function(e) {
e.preventDefault(); //prevent the default behaviour
$('#pagination').animate({
left: '-=100px'
},
500);
});
$('#prev_pag').click(function(e) {
e.preventDefault(); //prevent the default behaviour
$('#pagination').animate({
left: '+=100px'
},
500);
});
});
答案 1 :(得分:0)
尝试动画不是'marginLeft'而是'left'; 示例:强> http://www3.montonfashion.com/js/slider/carouselPP.js http://www3.montonfashion.com/et/waistcoat-willy.html
答案 2 :(得分:0)
您需要使用left
而不是marginleft
... see here
$('#next_pag').click(function() {
$('#pagination').animate({
left: '-=100px'
},
500);
});
$('#prev_pag').click(function() {
$('#pagination').animate({
left: '+=100px'
},
500);
});
});