Skip to content

Commit b3e94fa

Browse files
author
xrr2016
committed
⚡ another way
1 parent 95baab1 commit b3e94fa

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

15 - LocalStorage/index-FINISHED.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ <h2>LOCAL TAPAS</h2>
4545
}
4646

4747
function populateList(plates = [], platesList) {
48-
platesList.innerHTML = plates.map((plate, i) => {
49-
return `
50-
<li>
51-
<input type="checkbox" data-index=${i} id="item${i}" ${plate.done ? 'checked' : ''} />
52-
<label for="item${i}">${plate.text}</label>
53-
</li>
54-
`;
55-
}).join('');
48+
//once insert a node
49+
if(platesList.childNodes[1].textContent === 'Loading Tapas...'){
50+
platesList.removeChild(platesList.childNodes[1])
51+
}
52+
const plate = document.createElement('li')
53+
plate.innerHTML = `<label>${plates[plates.length - 1].text}</label>`
54+
platesList.appendChild(plate)
5655
}
5756

5857
function toggleDone(e) {
@@ -74,4 +73,3 @@ <h2>LOCAL TAPAS</h2>
7473

7574
</body>
7675
</html>
77-

0 commit comments

Comments
 (0)