<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
    <h2 class="title">週末 ToDo List<h2>
    <div class="container">
      <div class="list-container">
        <div>星期六</div>
        <div id="todo_sat">
          <li></li>
        </div>
      </div>
      <div class="list-container">
        <div>星期日</div>
        <div id="todo_sun">1231</div>
      </div>
     </div>
      <button class="button-action" id="asyncData">複製過去</button>
</body>
</html>
.title {
  color: #ff3c41;
}
.container {
  width: 100%;
  display: flex;
}
.list-container {
  width: 40%;
  background: #eee;
  margin: 5px;
  padding: 10px;
}
.button-action {
  color: #fff;
  background: blue;
  border: none;
  min-width: 100px;
  padding: 5px 10px;
  cursor: pointer;
}
.button-action:hover {
  opacity: 0.5;
}
.delete {
  float: right;
  cursor: pointer;
}
const satElem = document.querySelector('#todo_sat');
const sunElem = document.querySelector('#todo_sun');
const asyncDataElem = document.querySelector('#asyncData');

asyncDataElem.addEventListener('click', function(){
  sunData = satData;
  renderView();
})

let satData = ['運動', '看書', '研究投資'];
let sunData = ['睡午覺', '耍廢', '玩動森玩到爽'];

renderView();

function renderView(){
  satElem.innerHTML = renderList(satData, 1);
  sunElem.innerHTML = renderList(sunData, 2);
}

function renderList(values, type){
  let html = '';
  values.forEach((value, index) => {
    html += `<li>${value}<span class="delete" onclick="deleteData(${index}, ${type})">刪除</span></li>`
  })
  return html;
}
function deleteData(index, type){
  if(type === 1){
      satData.splice(index, 1);
  } else if(type === 2){
      sunData.splice(index, 1);
  }
  renderView();
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.