Guest_imported
New member
- Jan 1, 1970
- 0
If I have the code below in my html header and the items in the array are all ids of this type: <div id="main><!-- Stuff --></div>
Why am I getting an error that says object expected when I try to call the function?
ar_menu=new Array(
"main",
"music",
"media",
"biography",
"events",
"press",
"contacts",
)
var i;
var cur_item;
var pre_item = 0;
function posMenu () {
for (i=0; i<ar_menu.length; i++) {
cur_item = document.getElementById(ar_menu);
cur_item.style.top = pre_item+20+"px";
pre_item = pre_item+20;
}
}
Why am I getting an error that says object expected when I try to call the function?
ar_menu=new Array(
"main",
"music",
"media",
"biography",
"events",
"press",
"contacts",
)
var i;
var cur_item;
var pre_item = 0;
function posMenu () {
for (i=0; i<ar_menu.length; i++) {
cur_item = document.getElementById(ar_menu);
cur_item.style.top = pre_item+20+"px";
pre_item = pre_item+20;
}
}