<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> #ul1 { background-color: green; } #ul2 { background-color: yellow; } </style> <script type="text/javascript"> window.onload = function () { var oBtn = document.getElementById("btnChange"); var oUl1 = document.getElementById("ul1"); var oUl2 = document.getElementById("ul2"); var aLi = document.getElementsByTagName("li"); //for (var i = 0; i < aLi.length; i++) { // aLi[i].onclick = function () { // oUl1.removeChild(this); // oUl2.appendChild(this); // } //} oBtn.onclick = function () { var oLi = oUl1.children[0]; oUl1.appendChild(oLi) //oUl1.removeChild(oLi); //oUl2.appendChild(oLi);//1.先把元素从原有的父级别上删掉,在添加到新的父级上 } } </script> </head> <body> <ul id="ul1"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> <input type="button" value="移动" id="btnChange" /> <ul id="ul2"> </ul> </body> </html>