0

我目前正在将我的 HTML 转换为 WordPress 网站。该站点使用' inview' jQuery 插件。

我似乎无法让它在 WordPress 中工作。

我在 header.php 中插入了插件链接:src="js/jquery.inview.js"

以及以下内容footer.php

<script type="text/jscript">
$('#seoHomeImage, #socialBar').bind('inview', function(event, visible) {
if (visible) {
$(this).stop().animate({ opacity: 1 });
} else {
$(this).stop().animate({ opacity: 0 });
}
});
</script>

我也有这个来自Chris Coyiers Blank主题的功能:

if ( !is_admin() ) {
   wp_deregister_script('jquery');
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"), false);
   wp_enqueue_script('jquery');
}

我是否必须以某种方式链接inview功能页面内的“”插件?

感谢您的关注:-)

4

1 回答 1

0

当 DOM 完成事件时,您应该将此代码放入 document.ready 部分

    $(function () {
        $('#seoHomeImage, #socialBar').bind('inview', function(event, visible) {
            if (visible) {
                $(this).stop().animate({ opacity: 1 });
            } else {
                $(this).stop().animate({ opacity: 0 });
            }
        });
    });
于 2013-08-27T11:22:48.347 回答