Page 1 of 1

javascript object not letting me for loop

Posted: Tue Jan 24, 2012 5:33 pm
by danwguy
So I have a javascript object that I am passing to a function to iterate through it and add li items to a ul. when I console.log(typeof items) I get --- object. And when I console.log(items) I get --- ["<li class="0">Click Me</li>", "<li class="1">Click Me Too</li>"] ... so here is my function...

Code: Select all

setUpButtons: function(items) {
		console.log(typeof items);
		console.log(items);
			for(index in items) {
				console.log(items[0]);
				console.log("<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>");
			}
	}
It will not log anything except for the two logs outside of the for loop. I have also tried $(items).each(function() { console.log(this) } with nothing also. Anyone know why a for loop absolutely kills this?