Wordpress Jquery
直接调用WP自带的 jQuery
<?php wp_enqueue_script(‘jquery’); ?> 但要注意的是: wp_enqueue_script(‘jquery’); 必需加在 wp_head(); 的前面,且js代码不能使用$只能使用Jquery
使用Google api jquery
使WP自动包含jQuery:在主题文件的functions.php中添加如下代码:
if (!is_admin()) {
wp_deregister_script('jquery');
//解除默认注册脚本的jQuery
wp_enqueue_script('jquery',("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"));
//引用googleapi中的jQuery库
}
wp_deregister_script('jquery');
//解除默认注册脚本的jQuery
wp_enqueue_script('jquery',("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"));
//引用googleapi中的jQuery库
}