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 :)
精彩评论