【发布时间】:2012-07-10 12:56:12
【问题描述】:
在我的wordpress网站的functions.php中,我有这个代码来调用jquery:
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
但是,此代码与此 jquery 代码冲突:
$(function() {
$('#menu > li').hover(
function () {
var $this = $(this);
$('a',$this).stop(true,true).animate({
'bottom':'-55px' /* para não elevar muito o separador*/
}, 300);
$('i',$this).stop(true,true).animate({
'top':'-10px'
}, 400);
},
function () {
var $this = $(this);
$('a',$this).stop(true,true).animate({
'bottom':'-130px' /* para baixar o separador para o sitio original*/
}, 300);
$('i',$this).stop(true,true).animate({
'top':'50px'
}, 400);
}
);
});
我确定这是问题所在,因为如果我直接在页面头部调用http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js,插件就可以工作。我试图避免使用 jquery.noConflict 以避免同一页面上的其他 jquery 插件出现问题。
有什么提示吗?
【问题讨论】:
-
奇怪...我一直这样做,它对我有用。