我在我的项目中使用PagePiling ,特别是添加菜单的选项。
根据文档,您可以简单地添加 html:
<ul id="myMenu">
<li data-menuanchor="firstPage" class="active"><a href="#firstPage">First section</a></li>
<li data-menuanchor="secondPage"><a href="#secondPage">Second section</a></li>
<li data-menuanchor="thirdPage"><a href="#thirdPage">Third section</a></li>
<li data-menuanchor="fourthPage"><a href="#fourthPage">Fourth section</a></li>
</ul>
并在 js 中:
$('#pagepiling').pagepiling({
anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
menu: '#myMenu'
});
但是,我想添加动态菜单元素,例如:
<ul id="myMenu">
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li data-menuanchor="<?php sanitize_title(the_title()); ?>"><a href="#<?php sanitize_title(the_title()); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
我如何也更新js中的选项?