Javascript DOM HTML UL move <LI> element

Description

Javascript DOM HTML UL move <LI> element

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  w w  .j a  v a2s  .c o  m*/
  var node = document.getElementById("myList2").lastChild;
  var list = document.getElementById("myList1");
  list.insertBefore(node, list.childNodes[0]);
}
</script>

</body>
</html>



PreviousNext

Related