admin管理员组

文章数量:1406924

I badly need your help. I am having an error which is 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'appendTo' Here is my code:

<script type="text/javascript" src="js/jquery-1.6.min.js"></script>
<script src="js/cufon-yui.js" type="text/javascript"></script>
<script src="js/cufon-replace.js" type="text/javascript"></script>
<script src="js/Open_Sans_400.font.js" type="text/javascript"></script>
<script src="js/Open_Sans_Light_300.font.js" type="text/javascript"></script>
<script src="js/Open_Sans_Semibold_600.font.js" type="text/javascript"></script>
<script type="text/javascript" src="js/tms-0.3.js"></script> //error appears on this 
<script type="text/javascript" src="js/tms_presets.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script src="js/FF-cash.js" type="text/javascript"></script>
<script src="js/menu.js" type="text/javascript"></script>
<script type="text/javascript" src="js/html5.js"></script>


bannersFu:function(){
        var _=this
        if(_.banners===false)
            return false
        _.banners=[]
        $(_.items,_.me).each(function(i){
            var tmp
            _.banners[i]=(tmp=$('.'+_.bannerCl,this)).length?tmp:false
        })
        _.bannerShow(_.banner=_.banners[_.show].appendTo(_.me))//This is where the error es
    },

Your answers and opinion will be highly appreciated. Thank you.

I badly need your help. I am having an error which is 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'appendTo' Here is my code:

<script type="text/javascript" src="js/jquery-1.6.min.js"></script>
<script src="js/cufon-yui.js" type="text/javascript"></script>
<script src="js/cufon-replace.js" type="text/javascript"></script>
<script src="js/Open_Sans_400.font.js" type="text/javascript"></script>
<script src="js/Open_Sans_Light_300.font.js" type="text/javascript"></script>
<script src="js/Open_Sans_Semibold_600.font.js" type="text/javascript"></script>
<script type="text/javascript" src="js/tms-0.3.js"></script> //error appears on this 
<script type="text/javascript" src="js/tms_presets.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script src="js/FF-cash.js" type="text/javascript"></script>
<script src="js/menu.js" type="text/javascript"></script>
<script type="text/javascript" src="js/html5.js"></script>


bannersFu:function(){
        var _=this
        if(_.banners===false)
            return false
        _.banners=[]
        $(_.items,_.me).each(function(i){
            var tmp
            _.banners[i]=(tmp=$('.'+_.bannerCl,this)).length?tmp:false
        })
        _.bannerShow(_.banner=_.banners[_.show].appendTo(_.me))//This is where the error es
    },

Your answers and opinion will be highly appreciated. Thank you.

Share asked Jul 11, 2013 at 21:44 Gilbert JacobGilbert Jacob 1331 gold badge2 silver badges13 bronze badges 4
  • 3 most likely _.banners[_.show] isn't a jQuery object. (in your code it can be either a jQuery object or false. when it is false, it will fail.) – Kevin B Commented Jul 11, 2013 at 21:45
  • 1 @KevinB: Or undefined, if i never has whatever value is in _.show. – T.J. Crowder Commented Jul 11, 2013 at 21:48
  • Is it = or == in that line? – f p Commented Jul 11, 2013 at 21:49
  • 1 I would really, really not like to be the person who has to maintain that code. – T.J. Crowder Commented Jul 11, 2013 at 21:54
Add a ment  | 

1 Answer 1

Reset to default 4

You're calling appendTo on _.banners[_.show]. From your code, it's entirely possible that _.banners[_.show] could be either false or undefined, not a jQuery object.

If in the each loop, if i is ever equal to whatever is in _.show, then _.banners[_.show] will be either a jQuery object (with an appendTo method), or false (which doesn't have one), depending on whether $('.'+_.bannerCl,this) found any elements.

If i is never equal to _.show, then _.banners[_.show] will be undefined, which doesn't have an appendTo method.

The only way to figure out exactly what's going on is old-fashioned debugging: Use the debugger built into your browser, sets breakpoints, single-step through the code, inspect variables at various points in the debugger's display of variables, etc., etc.

本文标签: