0

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 comes
    },

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

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.) Commented Jul 11, 2013 at 21:45
  • 1
    @KevinB: Or undefined, if i never has whatever value is in _.show. Commented Jul 11, 2013 at 21:48
  • Is it = or == in that line? Commented Jul 11, 2013 at 21:49
  • 1
    I would really, really not like to be the person who has to maintain that code. Commented Jul 11, 2013 at 21:54

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok sir, I'll try your suggestion now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.