JQuery不能在Wordpress主题中工作
问题描述:
我无法从Functions.php入队JQuery。以下是我的功能。 谁能告诉我我错过了什么? 谢谢JQuery不能在Wordpress主题中工作
/**
* Enqueue scripts and styles.
*/
function bootstrap_framework_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_style('bootstrap-main-css', get_template_directory_uri() . '/bootstrap-css/bootstrap.min.css');
wp_enqueue_style('bootstrap-framework-style', get_stylesheet_uri());
wp_enqueue_script('bootstrap-main-js', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '20140924', true);
wp_enqueue_script('bootstrap-framework-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true);
wp_enqueue_script('ie10-viewport-bug-workaround', get_template_directory_uri() . '/js/ie10-viewport-bug-workaround.js', array(), '20140115', true);
wp_enqueue_script('offcanvas-fix', get_template_directory_uri() . '/js/offcanvas.js', array(), '20130119', true);
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
add_action('wp_enqueue_scripts', 'bootstrap_framework_scripts');
答
jQuery已经预先注册在最新版本的WordPress中;所以你不需要明确排队。
但是,WordPress附带的jQuery库设置为noConflict()模式,以防止WordPress可链接的其他JavaScript库的兼容性问题。阅读更多关于这对你意味着什么,in the Codex。
+0
非常感谢mevius。 – 2014-09-28 11:52:06
你找到了你的问题的答案? – rnevius 2014-09-27 10:35:15
是的,我确实得到了答案。谢谢 – 2014-09-28 11:52:51