开发者

JS - Object expected on new object();

What am i doing wrong here?

    var navbar = document.getElementById("navbar").getElementsByTagName("li");
    var hover;
    var moname;
    var slider;
    var newPos=new Object();
    var body=document.getElementsByTagName('body')[0];
    for (x in navbar) {
        if (x != 'length') {
            moname=(x+"-mo");
            hover=document.createElement("div");
            hover.setAttribute('id','slider');
            hover.setAttribute('name',moname);
         body.appendChild(hover);
            newPos.left=Posleft(x);
            newPos.top=PosTop(x);
            $('div.[name=moname]').offset(ne开发者_如何学运维wPos);
        }
    }

Every time it gets to

newPos.top=PosTop(x);   

It stops at newPos and says object expected. newPos is a new object though


Make sure your functions are named correctly, I think PosTop is a typo there since Posleft is lower-case and it's now blowing up on the line before. Always check the casing to make sure that the right-hand side of the operation is defined as well :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜