使用Visual Composer创建一个粘性侧边栏(WordPress)

时间:2017-10-11 14:02:03

标签: javascript jquery html css wordpress

我想用WordPress网站创建一个粘性侧边栏。遗憾的是,我无法为我的div添加更多ID和类,因为Visual Composer无法使用。这已经是我能得到的一切。

我正在使用我在GitHub上找到的Sticky Sidebar插件: https://abouolia.github.io/sticky-sidebar/

我已按照标题中所述嵌入脚本:

<script type="text/javascript" src="https://classymagazin.de/sticky-sidebar.js"></script>

到目前为止,这是我的代码:

<script type="text/javascript">
    var sidebar = new StickySidebar('#sidebarContainer', {
        containerSelector: '#sidebarContainer',
        innerWrapperSelector: '#stickySocialIcons',
        topSpacing: 20,
        bottomSpacing: 20
    });
</script>

但我的问题是,我总是收到这个错误:

  

未捕获的ReferenceError:未定义StickySidebar(索引):186

如何解决此问题并使我的侧栏粘滞?

我的侧栏是#sidebarContainer在此网站上:https://classymagazin.de/home/

亲切的问候

1 个答案:

答案 0 :(得分:0)

您可以像这样写入文档

    jQuery(document).ready(function(){var sidebar = new StickySidebar('#sidebarContainer', {containerSelector: '#sidebarContainer',
    innerWrapperSelector: '#stickySocialIcons',
    topSpacing: 20,
    bottomSpacing: 20});});