1
2
< ;span>3
var oDiv = document.getElementById("guoDiv");
var firsChild = oDiv.firstElementChild ? oDiv.firstElementChild : oDiv. firstChild
var returnNode = oDiv.removeChild(firsChild); //Remove the first element and return the removed element
alert(returnNode.innerHTML); //1
var lastChild = oDiv.lastElementChild ? oDiv .lastElementChild : oDiv.lastChild;
returnNode = oDiv.removeChild(lastChild); //Remove the last element and return the removed element
alert(returnNode.innerHTML);//3