Javascript 这个jQuery代码中的bug在哪里?
我有这个代码,/**/中的部分有一些错误。。。我找不到它。。。当我删除代码的这一部分时,它工作得很好 试试这个 在带有百分比的值周围缺少引号Javascript 这个jQuery代码中的bug在哪里?,javascript,jquery,html,css,hover,Javascript,Jquery,Html,Css,Hover,我有这个代码,/**/中的部分有一些错误。。。我找不到它。。。当我删除代码的这一部分时,它工作得很好 试试这个 在带有百分比的值周围缺少引号 $(this).animate({ width: 55% , height: 55% }, 250); }, function() { $(this).animate({ width: 50%, height: 50% }, 250); 应该是
$(this).animate({
width: 55% ,
height: 55%
}, 250);
}, function() {
$(this).animate({
width: 50%,
height: 50%
}, 250);
应该是
$(this).animate({
width: '55 %' ,
height: '55 %'
}, 250);
}, function() {
$(this).animate({
width: '50 %',
height: '50 %'
}, 250);
尝试创建百分比字符串,如下所示:
/* The buggy code starts here */
$('.menuCircle').hover(
function () {
$(this).animate({
width: '55%',
height: '55%'
}, 250);
},
function() {
$(this).animate({
width: '50%',
height: '50%'
}, 250);
});
/*it ends here*/
});
它可以工作,但不能产生动画。。我想我会坚持使用CSS:hover函数…如果你能解决这个问题,就说:)…我不能在9分钟内接受它,所以等一下:)当你去掉数字和%之间的空格时,它会有动画效果,但这有点奇怪…@davidebnar:是的,我知道当它没有%和数字之间的空格时,它会有动画效果,但我认为这是不一样的。现在将编辑我的回答OP还必须修改饼图切片的位置以使其看起来正确。@BNL所以我必须为每个切片生成不同的函数?这就是我不想做的:(。。。
/* The buggy code starts here */
$('.menuCircle').hover(
function () {
$(this).animate({
width: '55%',
height: '55%'
}, 250);
},
function() {
$(this).animate({
width: '50%',
height: '50%'
}, 250);
});
/*it ends here*/
});