javascript object not letting me for loop

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

javascript object not letting me for loop

Post 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?
Post Reply