jQuery插件在我的php页面中不起作用,在html中它运行正常

时间:2012-12-14 11:59:04

标签: php jquery

我正在使用PHP编码的网站。在这里我想添加jQuery插件Barousel。我在我网站外的HTML页面中测试过,它运行正常。但是当我在必须工作的页面中添加代码(PHP)时,它无法正常工作。

在Chrome中,我收到了下一条消息;

Uncaught Type Error: object#<object> has no method 'barousel'

This是页面。

图片必须是带文字的旋转木马。

任何人都可以帮助我;我真的不知道该怎么做。

1 个答案:

答案 0 :(得分:2)

您的页面头已加载jquery.js两次。

第二次加载将覆盖第一次加载,$.fn.barousel将不再定义。

<script type="text/javascript" src="jquery.js"></script>
<script src="barousel/js/jquery.barousel.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //BAROUSEL - ITEM NAVIGATION
        jQuery('#barousel_itemnav').barousel({
            manualCarousel: 0,
            slideDuration: 3000
        });
    });
</script>
<!-- remove this -->
<script type="text/javascript" src="jquery.js"></script>
<!-- remove this -->