在使用wordpress時,您應該在主題function.php中包含所有js調用。如果你是谷歌的wp_enqueue_script,你會發現很多資源。這裏有很長的路要走使用jQuery在Google的CDN:
function tm_javascript() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', false, '1.4.2', true);
wp_enqueue_script('jquery');
// load a JS file from my theme: js/theme.js
wp_enqueue_script('tm_filter', get_bloginfo('template_url') . '/js/filterable.js', array('jquery'), false, true);
wp_enqueue_script('tm_hash', get_bloginfo('template_url') . '/js/jquery.ba-hashchange.min.js', array('jquery'), false, true);
wp_enqueue_script('tm_ui', get_bloginfo('template_url') . '/js/jquery-ui-widget.js', array('jquery'), false, true);
wp_enqueue_script('tm_scroll', get_bloginfo('template_url') . '/js/jquery.smoothDivScroll-1.1-min.js', array('jquery', 'tm_ui'), false, true);
wp_enqueue_script('tm_ajaxaks', get_bloginfo('template_url') . '/js/aks.js', array('jquery', 'tm_hash', 'tm_filter', 'tm_ui', 'tm_scroll'), false, true);
}
}
add_action('init', 'tm_javascript');
的fridst部分註銷從WordPress的附帶的jQuery,然後加載實際的1.4.2版本。你可以修改代碼來加載總是最新的verion等。
然後,你可以從themes子文件夾/ js /加載你的主題特定的js文件,真正有用的部分是數組,你可以聲明依賴關係。恩。 smoothDicScroll插件需要在jquery和tm_ui(ui-widget)插件之後調用。
在你們所說的所有的JS腳本在頁腳結束
..
worls生活和與MAMP本地主機。在localhost上開發時,包含本地jquery版本的回退是很好的,因爲有時候你沒有連接到互聯網。
你得到了什麼錯誤信息?檢查Firefox中的錯誤控制檯。 – drudge 2010-11-17 00:00:45
你在寫什麼'src =「#」''爲什麼? – SLaks 2010-11-17 00:01:16