简体   繁体   English

为什么对象[ID]没有方法“动画”?

[英]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.

相关问题 TypeError:对象# <HTMLDivElement> 没有方法“动画” - TypeError: Object #<HTMLDivElement> has no method 'animate' jQuery-已赋予随机ID的Animate对象 - jQuery - Animate object that has been given a random id 在线出现“对象[object Object]没有方法”错误,但在本地主机上却没有! 为什么? - “Object [object Object] has no method” error online but not on localhost! Why? NodeJS-猫鼬,子文档对象没有方法.id()或.create() - NodeJS - Mongoose, subdoc object has no method .id() or .create() jQuery + Edge动画:仅在单击事件中调用时出错:对象[object Object]没有方法&#39;foundation&#39; - jQuery+Edge Animate: Error only when called from click event: Object [object Object] has no method 'foundation' stringByEvaluatingJavaScript对象没有ID - stringByEvaluatingJavaScript object has no ID 当DOM对象具有.toString()方法时,为什么要使用dom序列化程序 - Why use dom serializer when DOM object has .toString() method 为什么我在Javascript中收到错误消息对象没有方法? - Why do I get the error message Object has no method in Javascript? 对象没有方法推送 - Object has no method push 错误对象没有方法 - Error Object has no method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM