我对 Web 开发和编程完全陌生,我想在我的 WP 网站上使用 Scrollify。
所以我只想在一页中加载 Scrollify,所以我将它添加到functions.php
function load_js_assets() {
if( is_page( 26 ) ) {
wp_enqueue_script('scrollify', 'https://goodlifesoft.com/scrollify.js', array('jquery'), '', false);
}
}
我在控制台中添加了一条消息,以查看文件已加载。
我在header.php中加载了最新版本的 jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
我在footer.php中调用 Scrollify 函数
<script>
$(function() {
$.scrollify({
section : ".elementor-element.elementor-element.elementor-section-height-full.elementor-section-content-middle.elementor-section-boxed.elementor-section-height-default.elementor-section-items-middle.elementor-section.elementor-top-section",
});
});
</script>
这是我在控制台中收到的消息。来自控制台的内容
这在 JSfiddle https://jsfiddle.net/Balodis/w697stj5/60/中为我工作
如果有人能指出我做错了什么,我将非常感激。
谢谢!