window. onload = function(){
var ul2 = document.getElementById('ul2');
var oli = document.getElementsByTagName('li');
for(var i=0;i
ul2.appendChild(oli[i]);
}
}
Insert the content with Id ul1 into ul2
Insert the content of ul1 into ul2. This is actually moving rather than copying. Remember
Why This effect occurs because the length is changed due to constant moving during the loop. If you use for, the starting length has been fixed, so there is a problem, so it needs to be changed to
This is because the first one is inserted, so it is successful. You can try it.