更新时间:2023-10-31 12:13:22
有更优雅的方式来做到这一点,但是这是一个快速而肮脏的解决方案,您可以尝试。假设输出是在一个类别为'输出'的div里面。
There are far more elegant ways to do this, but here's a quick-and-dirty solution you might try. Assuming the output is inside a div with a class of 'output':
//Loop over list items
$('.wp-pagenavi ul').each(function(i, obj) {
var position = i + 1;
if($(this).hasClass('active')) {
$('.output').append('<span class="current">'+position+'</span>');
}
else {
$('.output').append('<a href="#" class="page">'+position+'</a>');
}
});
//Don't need this anymore
$('.wp-pagenavi ul').remove();