2012-02-15 108 views
0

我正在开发一个WordPress网站http://fremont.alchemycs.com,我一直在遇到jQuery问题。页面上有两个使用jQuery的功能 - 页面顶部的幻灯片显示和边栏中的手风琴菜单。出于某种原因,我无法让他们同时工作。根据我加载jQuery的位置,我得到“不是函数”的错误。jQuery加载问题

这里是我的头,因为它代表的时刻:

<!DOCTYPE html> 
<html dir="ltr" lang="en-US"> 
<head> 
<meta charset="UTF-8" /> 
<meta name="viewport" content="initial-scale=1.0, width=device-width" /> 
<title>Fremont, Seattle</title> 
<link rel="profile" href="http://gmpg.org/xfn/11" /> 
<link rel="stylesheet" type="text/css" media="all" href="http://fremont.alchemycs.com/wp-content/themes/center/style.css" /> 
<link rel="pingback" href="http://fremont.alchemycs.com/xmlrpc.php" /> 
<!-- 
<script src="http://fremont.alchemycs.com/wp-content/themes/center/js/modernizr-1.6.min.js"></script> 
--> 
<link rel="alternate" type="application/rss+xml" title="Fremont, Seattle &raquo; Feed" href="http://fremont.alchemycs.com/feed/" /> 
<link rel="alternate" type="application/rss+xml" title="Fremont, Seattle &raquo; Comments Feed" href="http://fremont.alchemycs.com/comments/feed/" /> 
<link rel="alternate" type="application/rss+xml" title="Fremont, Seattle &raquo; Home Comments Feed" href="http://fremont.alchemycs.com/home/feed/" /> 
<link rel='stylesheet' id='ccf_custom-css' href='http://fremont.alchemycs.com/wp-content/plugins/constant-contact-form/class/ccf_custom.css?ver=3.2.1' type='text/css' media='screen' /> 
<link rel='stylesheet' id='contact-form-7-css' href='http://fremont.alchemycs.com/wp-content/plugins/contact-form-7/styles.css?ver=3.1' type='text/css' media='all' /> 
<link rel='stylesheet' id='amr-ical-events-list-css' href='http://fremont.alchemycs.com/wp-content/plugins/amr-ical-events-list/css/icallist.css?ver=1' type='text/css' media='all' /> 

<link rel='stylesheet' id='amr-ical-events-list_print-css' href='http://fremont.alchemycs.com/wp-content/plugins/amr-ical-events-list/css/icalprint.css?ver=1' type='text/css' media='print' /> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/l10n.js?ver=20101110'></script> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/constant-contact-form/class/ccf_ajax.js?ver=3.2.1'></script> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/jquery-vertical-accordion-menu/js/jquery.hoverIntent.minified.js?ver=3.2.1'></script> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/jquery-vertical-accordion-menu/js/jquery.cookie.js?ver=3.2.1'></script> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/jquery-vertical-accordion-menu/js/jquery.dcjqaccordion.2.9.js?ver=3.2.1'></script> 
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/comment-reply.js?ver=20090102'></script> 
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://fremont.alchemycs.com/xmlrpc.php?rsd" /> 
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://fremont.alchemycs.com/wp-includes/wlwmanifest.xml" /> 

<link rel='index' title='Fremont, Seattle' href='http://fremont.alchemycs.com/' /> 
<link rel='next' title='Calendar' href='http://fremont.alchemycs.com/events/' /> 
<meta name="generator" content="WordPress 3.2.1" /> 

<!-- All in One SEO Pack 1.6.13.8 by Michael Torbert of Semper Fi Web Designob_start_detected [-1,-1] --> 
<meta name="description" content="The Center of the Universe" /> 
<link rel="canonical" href="http://fremont.alchemycs.com/" /> 
<!-- /all in one seo pack --> 
<link rel="stylesheet" type="text/css" href="http://fremont.alchemycs.com/wp-content/plugins/social-media-widget/social_widget.css" /> 
<link rel='stylesheet' id='wop-css' href='http://fremont.alchemycs.com/wp-content/plugins/widgets-on-pages/wop.css' type='text/css' media='all' /><!-- BEGIN Hackadelic Sliding Notes 1.6.5 --> 
<style type="text/css"> 
.concealed { display: none } 
.block { display: block } 
</style> 
<!-- END Hackadelic Sliding Notes 1.6.5 --> 

    <script src="http://fremont.alchemycs.com/wp-content/themes/center/js/jquery.flexslider.js"></script> 

    <link rel="stylesheet" type="text/css" media="all" href="http://fremont.alchemycs.com/wp-content/themes/center/css/flexslider.css" /> 
    <script type="text/javascript" charset="utf-8"> 
     $(window).load(function() { 
     $('.flexslider').flexslider(); 
     }); 
    </script> 

</head> 

当上面是我的头,我得到一个错误信息:$是不是一个函数

但是,如果我改变标题在稍后的头文件中加载jQuery,我得到了有关手风琴菜单功能的类似错误。

这可能很简单,但我很难搞清楚。

谢谢!

编辑 - 让我强调一下,我已经试过了我在哪里加载jQuery,即使我在页眉的顶部这样做,所以它是第一件事,只有一个脚本可以工作。

回答

0

确保装入了jQuery核心第一。 这意味着该行

<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script> 

应该是第一个脚本标记。

+0

现在,jQuery就是它插件放在那里的地方。但为了试图实现这一点,我删除了插件的jQuery调用,并将jQuery放在标题顶部。我仍然遇到同样的问题 - 页面上只有一个jQuery函数可以工作。 – Gwendydd 2012-02-15 22:03:40

+0

正如Tuncay Demirtepe所说,jQuery而不是$工作,由于某种原因,您的jQuery版本不正确,当我将http://code.jquery.com/jquery-1.6.1.min.js包含到您的页面中时很好。你应该使用jQuery(window)....或者用正确的版本覆盖文件。 – Qurben 2012-02-15 22:16:42

+0

你的文件确实是按照正确的顺序排列的,jQuery核心之前的文件与jQuery无关。 – Qurben 2012-02-15 22:20:23

0

你应该包括jquery.js先的插件js文件使用jQuery休息,为了此事确实,和包裹准备处理程序中的jQuery代码

$(function(){ 
// 
}); 
0

您必须添加的jQuery代码参考上述任何其他插件

<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script> 

相反你可以使用谷歌的lib参照最新的jQuery版本(1.7.1)

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> 

它应该增加下载时间给你的用户(它应该是第一个脚本标签)。

+0

正如我对Qurben所说的,我做到了这一点 - 我将jQuery放在页面的顶部,并且仍然只有页面上的一个jQuery函数可以工作。这里一定还有别的事情要做。 – Gwendydd 2012-02-15 22:04:32