views:

30

answers:

1

So, I need to remove all the child divs from a parent div using FBJS. I basically want to end up with an empty container div. Here is the code that I am using right now.

var events_next = document.getElementById('events-next');

for(var i=0; i < events_next.getChildNodes().length; i++) {
 events_next.removeChild(events_next.getFirstChild());
 console.log(i);
}

Now, the events_next.getChildNodes().length gives me the correct number of child nodes, but when the for loop is ran, it only cycles through and removes 2 or 3. I am very confused as to why its doing that and I could use any help!

I know no developer likes Facebook, but this is really annoying me! Thanks!

P.S. Anyway to find out my old username or whatever I used to register? I dont like having user90384 as my name.

A: 

use

var events_next = document.getElementById('events-next');
events_next.innerHTML="";
Lauri