[英]Why Object [ID] has no method 'Animate'?
I've created a fiddle here: http://jsfiddle.net/surfjam/zWWpz/ 我在这里创建了一个小提琴: http : //jsfiddle.net/surfjam/zWWpz/
I can't figure out why animate works in two instances, but not in another. 我不知道为什么动画会在两个实例中起作用,而在另一个实例中不起作用。 In the console error says "...no method 'Animate'..."
在控制台中,错误提示“ ...没有方法'Animate'...”
jQuery(document).ready(function($) {
var effect = "inm-shine";
$(".circle-button-border").mouseenter(function() {
$(this).addClass(effect);
$(this).stop(true, true).animate({
opacity: '0.85'
}, 'slow').css({
'z-index': '100',
top: '0',
left: '0'
});
//Error coming from this line...
$(this).parents('div:eq(0)').attr('id').animate({
height: '120%',
left: '0',
top: '0',
width: '120%'
}, 'fast');
}).mouseleave(function() {
$(this).animate({
opacity: '0'
}, 'fast');
});
});
SOLUTION: 解:
Thanks to the suggestions below, I've reworked the problem line like this: 由于以下建议,我对问题行做了如下修改:
var myId = $(this).parents('div:eq(0)').attr('id');
$('#' + myId).animate({
height: '110%',
left: '0',
top: '0',
width: 110%
}, 'fast');
Thanks for the help! 谢谢您的帮助!
attr('id')
返回一个字符串,因此您不再具有链接的jQuery对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.