بتل کد Battle Codeدارد باز می‌شود…

The Full List چالش 8 از جلسه‌ی 7، سخت

یک لیست کامل از صفر بساز. render(): برای هر کار li با checkbox (toggle(i))، span و دکمه‌ی .del با متن Delete (removeAt(i))؛ کلاس done برای کار انجام‌شده؛ #count مثل 1 of 2 done؛ #empty فقط وقتی لیست خالی است دیده شود. add با trim متن خالی را رد کند. toggle و removeAt آماده‌اند.

<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: Tahoma, sans-serif; max-width: 420px; margin: 0 auto; padding: 12px; }
li { padding: 8px 0; font-size: 18px; }

form { display: flex; column-gap: 8px; }
input { font-size: 16px; min-height: 44px; }
input[type="checkbox"] { min-height: 0; width: 24px; height: 24px; }
button { font-size: 16px; min-height: 44px; }

.done { text-decoration: line-through; color: gray; }
</style>
<h1>My Tasks</h1>
<form id="addForm" onsubmit="add(event)">
  <input id="t" placeholder="New task">
  <button>Add</button>
</form>
<ul id="list"></ul>
<p id="empty">Nothing to do!</p>
<p id="count"></p>
<script>
let todos = [];

function render() {
  // draw the list, the counter and the empty message
}

function add(event) {
  event.preventDefault();
}

render();
</script>

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 7: حذف و تیک

بیشتر بخوان: جاوااسکریپت چیست؟ از دکمه‌ی وب تا Node.js