Javascript DOM HTML Node appendChild() Method move <UL> item

Introduction

Move a list item from one list to another:

Click the button to move an item from one list to another.

View in separate window

<!DOCTYPE html>
<html>
<body>

<ul id="myList1"><li>CSS</li><li>HTML</li></ul>
<ul id="myList2"><li>SQL</li><li>Java</li></ul>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from  w ww  .  j av  a 2  s . c  o m
  var node = document.getElementById("myList2").lastChild;
  document.getElementById("myList1").appendChild(node);
}
</script>

</body>
</html>



PreviousNext

Related