Skip to content

Commit a9bcbe1

Browse files
committed
feat(JS): modify the event listener for the clear history button to toggle the display
1 parent c4b8538 commit a9bcbe1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,22 @@ function createHistoryList(array, element, history) {
297297
});
298298
}
299299

300+
// function togglesClearHistoryButton(element, btn) {
301+
// const hasChildElements = element.childElementCount > 0;
302+
// btn.classList.toggle("display", hasChildElements);
303+
// }
304+
305+
///
306+
clearHistoryBtn.addEventListener("click", () => {
307+
historyElement.innerHTML = "";
308+
togglesClearHistoryButton(historyElement, clearHistoryBtn);
309+
});
310+
300311
function togglesClearHistoryButton(element, btn) {
301-
if(element.childElementCount > 0) {
302-
btn.classList.toggle("display");
303-
}
312+
btn.classList.toggle("display", element.childElementCount > 0);
304313
}
305314

306315

316+
317+
307318
// functions creations ends

0 commit comments

Comments
 (0)