删除节点

118 阅读1分钟

删除

  • 1
  • 2
  • 3

<script>
    var ul = document.querySelector('ul');
    var btn = document.querySelector('button');

    btn.onclick = function () {
        if (ul.children.length == 0) {
            this.disabled = true;
        }else {
            ul.removeChild(ul.children[0]);
        }
    }

</script>