我在我的 WordPress 网站上运行 Foundation 6,我有一个工作正常的粘性 header 。但是当我添加自己的使用 onscroll 函数的 Jquery 函数时,标题停止工作。谁知道为什么?
JS:**
jQuery(window).on('scroll', function(){
var scrollTop = jQuery(window).scrollTop();
if(scrollTop > 265)
{
jQuery('.panel-grid-cell').addClass('hidden')();
}
});
<div id="top" class="show-for-<?php echo $breakpoint ?>" data-sticky-container>
<div class="sticky" data-sticky data-top-anchor="pgc-226-pgstart-0:top" data-btm-anchor="content:bottom" data-options="marginTop: 0" data-sticky-on="<?php echo $breakpoint ?>" style="width:100%;z-index:99;" id="menucontainer">
<div class="top-bar row" id="top-bar-menu" style="z-index:99;">
<div class="top-bar-left">
<?php if( get_field('website_logo', 'option') ): ?>
<a href="<?php echo get_site_url(); ?>"><img class="site-logo" src="<?php the_field('website_logo', 'option'); ?>" height="<?php the_field('logo_height', 'option'); ?>" alt="site-logo"></a>
<a href="<?php echo get_site_url(); ?>"><img class="site-logo-small site-logo-scroll" src="<?php the_field('website_logo_small', 'option'); ?>" height="<?php the_field('logo_height', 'option'); ?>" alt="site-logo"></a>
<?php endif; ?>
</div>
<div class="top-bar-right">
<?php joints_top_nav(); ?>
</div>
</div>
</div>
</div>
最佳答案
我找到了答案;我在我的 javascript 代码中打错了字:
jQuery('.panel-grid-cell').addClass('hidden')();
应该是:
jQuery('.panel-grid-cell').addClass('hidden');
关于jquery - 在滚动上使用 Jquery 时 Foundation 6 sticky 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40180398/