为什么点击事件无法传递自定义数据?我总是收到错误消息direction is not defined
这是我的代码:
function siblingPagination(page){
var el = $('.post-pagination > ul > li > .page-numbers:contains("' + page + '")').parent();
var list = {
prev : el.prev().find('.page-numbers'),
next : el.next().find('.page-numbers')
};
$.each( list, function(key){
$(this).addClass(key);
$(this).on('click',{direction: key}, function(e){
e.preventDefault();
$('html, body').animate({
scrollTop : $('.js-load-more.' + event.data.direction + '').offset().top-30
}, 'slow');
});
});
}
答案 0 :(得分:1)
将event.data.direction
替换为e.data.direction