“jQuery(”#marquee“)。marquee不是一个函数”错误

时间:2012-02-07 20:02:49

标签: jquery jquery-plugins marquee

我正在尝试使用jQuery的marquee插件 但我在FireBug控制台jQuery("#marquee").marquee is not a function中收到此错误 我的代码是这样的:

<script src="jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery.marquee.js" type="text/javascript"></script>
<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function (){ 
        jQuery("#marquee").marquee(); 
    });
</script>

我的html是:

<ul id="marquee" class="marquee"> 
  <li>Some text</li>
</ul>

我正在使用这个字幕插件:
http://www.givainc.com/labs/marquee_jquery_plugin.htm

有什么问题?

----- ----- EDIT
我在一个独立的页面上测试了它,除了字幕代码之外什么都没有,它起作用了! 我认为我正在使用的其他图书馆正在制造问题 我的整个<head>是:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
<meta name="generator" content="Joomla! 1.7 - Open Source Content Management" />
<title>title</title>
<link href="/joomla/index.php?option=com_content&amp;view=category&amp;layout=blog&amp;id=89&amp;Itemid=559&amp;format=feed&amp;type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />
<link href="/joomla/index.php?option=com_content&amp;view=category&amp;layout=blog&amp;id=89&amp;Itemid=559&amp;format=feed&amp;type=atom" rel="alternate" type="application/atom+xml" title="Atom 1.0" />
<link href="http://localhost/joomla/index.php?option=com_search&amp;view=category&amp;layout=blog&amp;id=89&amp;Itemid=559&amp;format=opensearch" rel="search" title="title" type="application/opensearchdescription+xml" />
<link rel="stylesheet" href="/joomla/media/system/css/modal.css" type="text/css" />
<link rel="stylesheet" href="/joomla/plugins/content/attachments/attachments.css" type="text/css" />
<link rel="stylesheet" href="/joomla/plugins/content/attachments/attachments1.css" type="text/css" />
<link rel="stylesheet" href="media/system/css/jquery.marquee.css" type="text/css" />
<script src="/joomla/media/system/js/core.js" type="text/javascript"></script>
<script src="/joomla/media/system/js/mootools-core.js" type="text/javascript"></script>
<script src="/joomla/media/system/js/caption.js" type="text/javascript"></script>
<script src="/joomla/media/system/js/mootools-more.js" type="text/javascript"></script>
<script src="/joomla/media/system/js/modal.js" type="text/javascript"></script>
<script src="/joomla/plugins/content/attachments/attachments_refresh.js" type="text/javascript"></script>
<script src="media/system/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="media/system/js/jquery.marquee.js" type="text/javascript"></script>
<script type="text/javascript">
function keepAlive() {  var myAjax = new Request({method: "get", url: "index.php"}).send();} window.addEvent("domready", function(){ keepAlive.periodical(840000); });
    window.addEvent('domready', function() {

        SqueezeBox.initialize({});
        SqueezeBox.assign($$('a.modal'), {
            parse: 'rel'
        });
    });
    window.addEvent('domready', function() {

        SqueezeBox.initialize({});
        SqueezeBox.assign($$('a.modal-button'), {
            parse: 'rel'
        });
    });

jQuery.noConflict();
jQuery(document).ready(function (){ 
    jQuery("#marquee").marquee(); 
});
</script>
<link type="text/css" rel="stylesheet" href="http://localhost/joomla/plugins/content/jumultithumb/assets/style.css" />
<link rel="stylesheet" href="/joomla/templates/siteground-j16-25/css/template.css" type="text/css" />
<script type="text/javascript" src="/joomla/templates/siteground-j16-25/js/CreateHTML5Elements.js"></script>
<script type="text/javascript" src="/joomla/templates/siteground-j16-25/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript" src="/joomla/templates/siteground-j16-25/js/sgmenu.js"></script>

2 个答案:

答案 0 :(得分:4)

看到您更新的问题,问题很明显。你正在第二次加载jquery(第3行),这当然会覆盖之前加载的所有插件。由于对.marquee的调用是异步的(回调到ready事件),插件在调用回调时就消失了。

解决方案:第二次加载jquery时删除。

答案 1 :(得分:1)

尝试这个:

<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function (){ 
        jQuery("#marquee").marquee(); 
    });
</script>
身体

以下是我所谈论的一个例子:http://jsfiddle.net/mjgasner/m64xQ/

现在它不起作用,但如果你将javascript加载更改为nowrap(body),它就可以工作。